I looked at the ruby documentation for StringIO, and it looks like what you want is StringIO#string, not StringIO#to_s
Thus, change your code to:
s = StringIO.new
s << 'foo'
s << 'bar'
s.string
I looked at the ruby documentation for StringIO, and it looks like what you want is StringIO#string, not StringIO#to_s
Thus, change your code to:
s = StringIO.new
s << 'foo'
s << 'bar'
s.string