Class: Pmux::PipeIO

Inherits:
IO
  • Object
show all
Defined in:
lib/pmux/pipeio.rb

Instance Method Summary collapse

Constructor Details

#initialize(cmd, mode = 'r') ⇒ PipeIO

Returns a new instance of PipeIO.



3
4
5
6
7
# File 'lib/pmux/pipeio.rb', line 3

def initialize cmd, mode='r'
  io = IO.popen cmd, mode
  super io
  @on_receive = nil
end

Instance Method Details

#on_read(data) ⇒ Object



13
14
15
16
17
# File 'lib/pmux/pipeio.rb', line 13

def on_read data
  if @on_receive
    @on_receive.call data
  end
end

#on_receive(&block) ⇒ Object



9
10
11
# File 'lib/pmux/pipeio.rb', line 9

def on_receive &block
  @on_receive = block
end