Skip to main content
100%

Gist 60785

✓ Published0🌍 Public
DDylanFM
Last edited Feb 9, 2009
Created on Feb 9, 2009

This example demonstrates a minimal Ruby script that temporarily redirects standard output to capture a string, then restores it and prints the captured content. It shows how to intercept output using `StringIO` and the global `$stdout` variable. The code assigns `$stdout` to a new `StringIO` object, prints "Hello, World!" into it, then restores the original standard output and outputs the captured string via `new_stdout.string`. The visible rendering is plain text output, with no external data source or graphical library involved.

AI-generated description

Similar vizzes