I recently read a nice post on using StringIO in Ruby. What the author doesn\'t mention, though, is that StringIO is just an \"I.\" There\'s no \
StringIO
I looked at the ruby documentation for StringIO, and it looks like what you want is StringIO#string, not StringIO#to_s
StringIO#to_s
Thus, change your code to:
s = StringIO.new s << 'foo' s << 'bar' s.string