Writing to a file

Hey guys, can anyone explain how to write to a file in Ruby?

Thanks,

Mike

Have you heard about google ?

http://snippets.dzone.com/posts/show/5051
http://www.ruby-doc.org/core/classes/File.html
http://forums.site5.com/showthread.php?t=8163


http://blog.eugen.co

Take a look at http://www.oldkingjames.org it has Ruby lessons for
beginners in Learn to program and there are a couple of pages that deal
with the File modes r r+ w w+ a a+ b used to write to files.

Easiest way is to open a file for writing and with a block write the
contents to it.

File.open(“test_file.txt”, “a+”) do |file| #opens the file
“test_file.txt” in append mode, if it does not exist it creates it.
file.puts “Hello world”
end #closes the file for you

Otherway is to use File.new but that forces you to ensure to close the
file etc.

Regards,
Vicente