$stdout ruby override
class CustomStdout
def write(message)
# Custom logic for processing the message before printing
processed_message = message.upcase
# Original STDOUT functionality
$stdout.write(processed_message)
end
end
# Create an instance of CustomStdout
custom_stdout = CustomStdout.new
# Redirect the standard output to the custom instance
$stdout = custom_stdout
# Your code that generates output
puts "Hello, World!"
# Restore the original STDOUT to avoid interference with subsequent output
$stdout = STDOUT