From: Bill Kelly Date: 2001-12-20T20:56:40+09:00 Subject: [ruby-talk:29097] Re: Stream? From: "Ron Jeffries" > Well, the idea is to set up a stream on a string and then pass it to a > method that expects a file, for testing purposes. So I can do it to > the extent that the method only uses methods that Strings understand. Here's a thought: require 'tempfile' class String def as_file() tf = Tempfile.new("ruby.strio.") tf.print(self) tf.close tf.open end end irb(main):071:0> f = "bang!\nzoom!!\n".as_file # irb(main):072:0> f.path "/cygdrive/c/temp/ruby.strio.760.0" irb(main):073:0> f.gets "bang!\n" irb(main):074:0> f.gets "zoom!!\n" Regards, Bill