module IO

redirect

Public Class Methods

redirect(stdout) { || ... } click to toggle source

Redirect stdout to STDOUT and executes the block.

# File lib/el4r/el4r-sub.rb, line 519
def redirect(stdout)
  begin
    stdout_sv = STDOUT.dup
    STDOUT.reopen(stdout)
    yield
  ensure
    STDOUT.flush
    STDOUT.reopen(stdout_sv)
  end
end