class Pull::Collect
Constants
- DEFAULT_DONE_CALLBACK
Attributes
block[R]
Public Class Methods
new(&block)
click to toggle source
# File lib/pull/sink/collect.rb, line 9 def initialize(&block) @block = block @collection = [] end
Public Instance Methods
call(read, done = DEFAULT_DONE_CALLBACK)
click to toggle source
# File lib/pull/sink/collect.rb, line 14 def call(read, done = DEFAULT_DONE_CALLBACK) raise TypeError unless read.respond_to?(:call) drained = Pull::Drain.new do |value| @collection << value end drained.(read) block.call(@collection) end