Class: Kward::PassthroughPtyOutputSink
- Inherits:
-
Object
- Object
- Kward::PassthroughPtyOutputSink
- Defined in:
- lib/kward/pty/output_sink.rb
Overview
Forwards PTY output immediately and optionally keeps a bounded byte copy.
The runner only depends on the sink's write method and optional flush
method. Capture is deliberately byte-oriented so PTY chunk boundaries have
no effect on the retained output.
Instance Attribute Summary collapse
-
#captured_output ⇒ Object
readonly
Returns the value of attribute captured_output.
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(output:, max_capture_bytes: nil) ⇒ PassthroughPtyOutputSink
constructor
A new instance of PassthroughPtyOutputSink.
- #truncated? ⇒ Boolean
- #write(chunk) ⇒ Object
Constructor Details
#initialize(output:, max_capture_bytes: nil) ⇒ PassthroughPtyOutputSink
Returns a new instance of PassthroughPtyOutputSink.
63 64 65 66 67 68 |
# File 'lib/kward/pty/output_sink.rb', line 63 def initialize(output:, max_capture_bytes: nil) @output = output @max_capture_bytes = max_capture_bytes @captured_output = max_capture_bytes ? +"".b : nil @truncated = false end |
Instance Attribute Details
#captured_output ⇒ Object (readonly)
Returns the value of attribute captured_output.
61 62 63 |
# File 'lib/kward/pty/output_sink.rb', line 61 def captured_output @captured_output end |
Instance Method Details
#flush ⇒ Object
75 76 77 |
# File 'lib/kward/pty/output_sink.rb', line 75 def flush @output.flush if @output.respond_to?(:flush) end |
#truncated? ⇒ Boolean
79 80 81 |
# File 'lib/kward/pty/output_sink.rb', line 79 def truncated? @truncated end |
#write(chunk) ⇒ Object
70 71 72 73 |
# File 'lib/kward/pty/output_sink.rb', line 70 def write(chunk) @output.write(chunk) capture(chunk) end |