I'm not sure this is useful, but you can certainly redirect standard output to a variable. For example:
# Set up standard output as a StringIO object. foo = StringIO.new $stdout = foo # Send some text to $stdout. puts 'hi' puts 'bye' # Access the data written to standard output. $stdout.string # => "hi\nbye\n" # Send your captured output to the original output stream. STDOUT.puts $stdout.string
In practice, this is probably not a great idea, but at least now you know it's possible.