Class: Mediakit::Process::Runner::IOWatcher

Inherits:
Coolio::IO
  • Object
show all
Defined in:
lib/mediakit/process/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, &block) ⇒ IOWatcher

Returns a new instance of IOWatcher.



115
116
117
118
119
120
# File 'lib/mediakit/process/runner.rb', line 115

def initialize(io, &block)
  @io = io
  @block = block
  @data = ''
  super
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



113
114
115
# File 'lib/mediakit/process/runner.rb', line 113

def data
  @data
end

#ioObject (readonly)

Returns the value of attribute io.



113
114
115
# File 'lib/mediakit/process/runner.rb', line 113

def io
  @io
end

Instance Method Details

#on_closeObject



127
128
129
# File 'lib/mediakit/process/runner.rb', line 127

def on_close
  @block = nil
end

#on_read(data) ⇒ Object



122
123
124
125
# File 'lib/mediakit/process/runner.rb', line 122

def on_read(data)
  @block.call(data)
  @data << data
end

#readObject



131
132
133
134
# File 'lib/mediakit/process/runner.rb', line 131

def read
  @data << @io.read unless @io.closed?
  @io.close unless @io.closed?
end