Module: Waterslide::Pipe
- Included in:
- NoOp
- Defined in:
- lib/waterslide.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.[](things) ⇒ Object
21 22 23 24 |
# File 'lib/waterslide.rb', line 21 def self.[] (things) things = [things] unless things.respond_to? :each NoOp.new.receive_from(things) end |
.included(base) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/waterslide.rb', line 14 def self.included(base) base.class_eval do include Enumerable include RightShiftOverride end end |
Instance Method Details
#all ⇒ Object
42 43 44 45 46 |
# File 'lib/waterslide.rb', line 42 def all all = [] each { |one| all << one } all end |
#each ⇒ Object
31 32 33 34 35 |
# File 'lib/waterslide.rb', line 31 def each incoming.each do |one| pipe_one(one) { |out| yield out } end end |
#receive_from(enumerable) ⇒ Object
26 27 28 29 |
# File 'lib/waterslide.rb', line 26 def receive_from(enumerable) @incoming = enumerable self end |
#take ⇒ Object
37 38 39 40 |
# File 'lib/waterslide.rb', line 37 def take each { |one| return one } return nil # if nothing was yielded end |