Module: Kernel
- Defined in:
- lib/iron/extensions/kernel.rb
Instance Method Summary collapse
-
#capture_stdout ⇒ Object
Captures STDOUT content and returns it as a string.
Instance Method Details
#capture_stdout ⇒ Object
Captures STDOUT content and returns it as a string
>> capture_stdout do
>> puts 'Heya'
>> end
=> "Heya\n"
11 12 13 14 15 16 17 18 |
# File 'lib/iron/extensions/kernel.rb', line 11 def capture_stdout # :yields: out = StringIO.new $stdout = out yield return out.string ensure $stdout = STDOUT end |