Module: Whatup::Server::Redirection

Included in:
DbInit, Server
Defined in:
lib/whatup/server/redirection.rb

Instance Method Summary collapse

Instance Method Details

#redirect(stdin: $stdin, stdout: $stdout) ⇒ Object

Reroutes stdin and stdout inside a block

Parameters:

  • stdin (IO#write) (defaults to: $stdin)
    • will redirect stdin to this

  • stdout (IO#write) (defaults to: $stdout)
    • will redirect stdout to this



10
11
12
13
14
15
16
17
18
19
# File 'lib/whatup/server/redirection.rb', line 10

def redirect stdin: $stdin, stdout: $stdout
  original_stdin  = $stdin
  original_stdout = $stdout
  $stdin  = stdin
  $stdout = stdout
  yield
ensure
  $stdin  = original_stdin
  $stdout = original_stdout
end