Class: InternetHakai::RevPipe

Inherits:
Object
  • Object
show all
Extended by:
Rev::Meta
Defined in:
lib/internethakai/hakairev/revpipe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRevPipe

Returns a new instance of RevPipe.



4
5
6
7
8
# File 'lib/internethakai/hakairev/revpipe.rb', line 4

def initialize
    r, w = ::IO::pipe
    @reader = RWatcher::new(r)
    @writer = Rev::IO::new(w)
end

Instance Attribute Details

#readerObject (readonly)

Returns the value of attribute reader.



9
10
11
# File 'lib/internethakai/hakairev/revpipe.rb', line 9

def reader
  @reader
end

Instance Method Details

#attach(loop) ⇒ Object



10
11
12
13
14
# File 'lib/internethakai/hakairev/revpipe.rb', line 10

def attach(loop)
    @loop = loop
    @reader.attach(@loop) unless @reader.attached?
    @writer.attach(@loop) unless @writer.attached?
end

#on_read(&block) ⇒ Object



18
19
20
# File 'lib/internethakai/hakairev/revpipe.rb', line 18

def on_read &block
    @reader.on_read(&block)
end

#write(data) ⇒ Object



15
16
17
# File 'lib/internethakai/hakairev/revpipe.rb', line 15

def write(data)
    @writer.write(data)
end