Главная
translate
Войти
Регистрация
Форум
Блоги
Пользователи
Список джемов
Rails проекты
Поиск
Loading...
Login form
Ruby On Rails in UA
/
Code Review, теоретические вопросы
/
Работа с содержимым файла
/
Записываем в файл
назад
новый
ответить
2008-06-10 04:17:33
Ответить
Ruslan Voloshin
Адрес:
odessa
Сообщений: 1296
Регистр: 2007-03-13
его блог
40 сообщ.
Записываем в файл
open('output', 'w') { |f| f << "This file contains great truths.\n" } open('output', 'w') do |f| f.puts 'The great truths have been overwritten with an advertisement.' end open('output') { |f| f.read } # => "The great truths have been overwritten with an advertisement.\n" #--- open('output', "a") { |f| f.puts 'Buy Ruby(TM) brand soy sauce!' } open('output') { |f| puts f.read } # The great truths have been overwritten with an advertisement. # Buy Ruby(TM) brand soy sauce! #--- open('output', 'w') do |f| [1,2,3].each { |i| f << i << ' and a ' } end open('output') { |f| f.read } # => "1 and a 2 and a 3 and a " #--- open('output', 'w') do |f| f << 'This is going into the Ruby buffer.' f.flush # Now it's going into the OS buffer. end IO.sync = false open('output', 'w') { |f| f << 'This is going straight into the OS buffer.' }
------------
Занимаюсь вебом и продвижением сайтов.
open
назад
новый
ответить
Ключевые слова:
class [1]
globalize [2]
each_with_index [1]
rake tmp [1]
Qt [1]
images [1]
YAML.load_file [1]
tasks [1]
hash.values [1]
rails WYSIWYG [2]
flash [2]
request [1]
Apple и Ruby [1]
fleximage [1]
yml [1]
Acts_as_taggable_on_steroids [5]
Ubuntu [4]
has and belongs to many [2]
basic authorization [2]
rails 1.2.5 [1]
Гости: 106 Онлайн:
Виктор
,
О проекте
по всем вопросам обращайтесь на
support
Rubyclub.com.ua
Copyright © 2007 - 2008