Class: Tetra::ProcessRunner::RecordingIO

Inherits:
Object
  • Object
show all
Defined in:
lib/tetra/facades/process_runner.rb

Overview

records bytes sent via “<<” for later use optionally echoes to another IO object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io = nil) ⇒ RecordingIO

Returns a new instance of RecordingIO.



50
51
52
53
# File 'lib/tetra/facades/process_runner.rb', line 50

def initialize(io = nil)
  @io = io
  @record = ""
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record.



48
49
50
# File 'lib/tetra/facades/process_runner.rb', line 48

def record
  @record
end

Instance Method Details

#<<(*args) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/tetra/facades/process_runner.rb', line 55

def <<(*args)
  if @io
    @io.<<(*args)
    @io.flush
  end
  @record.<<(*args)
end