> I have to define File.write() for each project...
Do you mean you want:
File.write(filename, string)
to overwrite the contents of the named file with the contents of the
string?
I'd just do
File.open(filename,"w") { |f| f << string }
It's not much more typing. If you use it lots, then as you say, you can
write your own method to do it.
I find normally I'm doing something else, e.g. streaming an existing
open I/O object into a file:
IO.popen("...") do |src|
File.open(file2,"w") do |dst|
while data = src.read(16384)
dst << data
end
end
end
But it doesn't worry me that Ruby doesn't provide this natively, since
it's so easy to construct from the tools provided.
Regards,
Brian.
--
Posted via http://www.ruby-forum.com/.