From: Suraj Kurapati Date: 2009-02-01T02:53:17+09:00 Subject: Re: File::write() complement for File::read() ? Rob Biedenharn wrote: > $ fri File#write > [...] > It's already there. This method is an instance method. I asked for a class method File::write (just like File::read) not an instance method File#write. > Your method would be incomplete without a mode. Do you want 'w', 'a', > 'wb', etc.? > > def your_write(path, data, mode='wb') > File.open(path, mode) {|f| f.write data } > end Good point. > I don't know why you call #to_s on data if you open 'wb'. (IO#write > does that for you if what you pass isn't a String.) Thanks for the tip. -- Posted via http://www.ruby-forum.com/.