Skip to content
Kward Search API index

Class: Kward::PassthroughPtyOutputSink

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

Instance Method Summary collapse

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_outputObject (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

#flushObject



75
76
77
# File 'lib/kward/pty/output_sink.rb', line 75

def flush
  @output.flush if @output.respond_to?(:flush)
end

#truncated?Boolean

Returns:

  • (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