Class: RackConsole::OutputCapture
- Inherits:
-
Object
- Object
- RackConsole::OutputCapture
- Defined in:
- lib/rack_console/output_capture.rb
Instance Method Summary collapse
- #capture ⇒ Object
-
#initialize ⇒ OutputCapture
constructor
A new instance of OutputCapture.
- #output ⇒ Object
- #write(value) ⇒ Object
Constructor Details
#initialize ⇒ OutputCapture
Returns a new instance of OutputCapture.
5 6 7 8 9 |
# File 'lib/rack_console/output_capture.rb', line 5 def initialize @old = $stdout @io = ::StringIO.new @main_thread = ::Thread.current end |
Instance Method Details
#capture ⇒ Object
15 16 17 18 19 20 |
# File 'lib/rack_console/output_capture.rb', line 15 def capture $stdout = self yield ensure $stdout = @old end |
#output ⇒ Object
22 23 24 25 |
# File 'lib/rack_console/output_capture.rb', line 22 def output @io.rewind @io.read end |
#write(value) ⇒ Object
11 12 13 |
# File 'lib/rack_console/output_capture.rb', line 11 def write(value) io.write(value) end |