On Wed, 19 Dec 2001, Ron Jeffries wrote:
> Is there a memory stream object in Ruby, analogous to Smalltalk's
> 	ReadStream on: "abcdefghij"?

I suppose you wish to treat a String object as an IO object? If so, I'll
say it's not written yet, but could be by 2002. Depends on whether you
want to pair with me. It would be an abstract IO class (possibly broken
down in smaller pieces) and an application piece of code similar to the
one below.

The opposite, IO as String, has not been done yet either, but it will be 
done in 5 minutes... [...] done! ;-)

require "Hollow/String" # from M˝ŇaRuby 0.7
class IOAsString; include HollowString, SimpleStringP
  def initialize(io) @io=io end
  def get i; (get_seq i,1)[0] end
  def put i,v; put_seq i,1,v.chr end
  def get_seq i,n
    @io.seek i, IO::SEEK_SET
    @io.read n
  end
  def put_seq i,n,v
    n!=v.length and raise "can't insert nor delete, sorry!"
    @io.seek i, IO::SEEK_SET
    @io.write v
  end
  def length
    @io.seek 0, IO::SEEK_END
    @io.tell
  end
end

________________________________________________________________
Mathieu Bouchard                   http://hostname.2y.net/~matju