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