module Kernel

thinkingdigitally.com/archive/capturing-output-from-puts-in-ruby/

Public Instance Methods

capture_stdout() { || ... } click to toggle source
# File lib/cutter/kernel.rb, line 5
def capture_stdout
  out = StringIO.new
  $stdout = out

  yield

  out
ensure
  $stdout = STDOUT
end