capture

capture(stream)
Instance Public methods

Captures the given stream and returns it:

stream = capture(:stdout) { puts 'notice' }
stream # => "notice\n"

stream = capture(:stderr) { warn 'error' }
stream # => "error\n"

even for subprocesses:

stream = capture(:stdout) { system('echo notice') }
stream # => "notice\n"

stream = capture(:stderr) { system('echo error 1>&2') }
stream # => "error\n"

silence

doc_ruby_on_rails
2015-06-20 00:00:00
Comments
Leave a Comment

Please login to continue.