Class: WrapIO::Capture
- Inherits:
-
Object
- Object
- WrapIO::Capture
- Defined in:
- lib/wrapio/capture.rb
Overview
A small class built to capture the output from STDOUT.
Class Method Summary collapse
-
.output { ... } ⇒ Object
Captures the output of $stdout.
Class Method Details
.output { ... } ⇒ Object
Captures the output of $stdout. Temporarily swaps $stdout with an instance of the StringIO
class.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/wrapio/capture.rb', line 14 def self.output begin $stdout = captor = StringIO.new yield ensure $stdout = STDOUT end WrapIO.log(captor.string, :output) if WrapIO.debug captor.string end |