Class: RSwim::Pipe

Inherits:
Object
  • Object
show all
Defined in:
lib/rswim/pipe.rb

Direct Known Subclasses

Simple

Defined Under Namespace

Classes: Simple

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(q_in, q_out) ⇒ Pipe

Returns a new instance of Pipe.



9
10
11
12
# File 'lib/rswim/pipe.rb', line 9

def initialize(q_in, q_out)
  @q_in = q_in
  @q_out = q_out
end

Class Method Details

.simpleObject



5
6
7
# File 'lib/rswim/pipe.rb', line 5

def self.simple
  Simple.new
end

Instance Method Details

#inboundObject

returns list of inputs. Empty if none have been received



19
20
21
# File 'lib/rswim/pipe.rb', line 19

def inbound
  Array.new(@q_in.size) { @q_in.pop }.tap(&:compact!)
end

#send(message) ⇒ Object



14
15
16
# File 'lib/rswim/pipe.rb', line 14

def send(message)
  @q_out << message
end