Class: Byebug::DAP::CapturedOutput Private
- Inherits:
-
Object
- Object
- Byebug::DAP::CapturedOutput
- Defined in:
- lib/byebug/dap/helpers/captured_output.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Captures an IO output stream.
Instance Attribute Summary collapse
-
#captured ⇒ std:IO
readonly
private
The captured stream.
-
#original ⇒ std:IO
readonly
private
The original stream, duplicated from ‘io`.
Instance Method Summary collapse
-
#initialize(io) ⇒ CapturedOutput
constructor
private
Capture ‘io`, duplicate the original, open an pipe pair, and reopen `io` to redirect it to the pipe.
-
#restore ⇒ Object
private
Restore ‘io` to the original file.
Constructor Details
#initialize(io) ⇒ CapturedOutput
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Capture ‘io`, duplicate the original, open an pipe pair, and reopen `io` to redirect it to the pipe.
16 17 18 19 20 21 22 23 |
# File 'lib/byebug/dap/helpers/captured_output.rb', line 16 def initialize(io) @io = io @original = io.dup @captured, pw = IO.pipe io.reopen(pw) pw.close end |
Instance Attribute Details
#captured ⇒ std:IO (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The captured stream. Captured output can be read from this IO.
12 13 14 |
# File 'lib/byebug/dap/helpers/captured_output.rb', line 12 def captured @captured end |
#original ⇒ std:IO (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The original stream, duplicated from ‘io`. Writing to this IO will write to the original file.
8 9 10 |
# File 'lib/byebug/dap/helpers/captured_output.rb', line 8 def original @original end |
Instance Method Details
#restore ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Restore ‘io` to the original file.
26 27 28 29 30 31 |
# File 'lib/byebug/dap/helpers/captured_output.rb', line 26 def restore @io.reopen(@original) @original.close @captured.close return nil end |