From: "Ron Jeffries" <ronjeffries / REMOVEacm.org>

> 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
#<File:0xa121b80>
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