require 'tempfile' out = Tempfile.new("tempfile") out.path out << "Some text." out.rewind out.read out.close