Class: Byebug::DAP::CapturedOutput Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#capturedstd: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.

Returns:

  • (std:IO)


12
13
14
# File 'lib/byebug/dap/helpers/captured_output.rb', line 12

def captured
  @captured
end

#originalstd: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.

Returns:

  • (std:IO)


8
9
10
# File 'lib/byebug/dap/helpers/captured_output.rb', line 8

def original
  @original
end

Instance Method Details

#restoreObject

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