Write to a string
require 'stringio' s = StringIO.new s.write('Treat it like a file.') s.rewind s.write("Act like it's") s.string # => "Act like it's a file."