class Bud::PushReduce

Public Class Methods

new(elem_name, bud_instance, collection_name, schema_in, initial, &blk) click to toggle source
Calls superclass method Bud::PushElement::new
# File lib/bud/executor/elements.rb, line 506
def initialize(elem_name, bud_instance, collection_name,
               schema_in, initial, &blk)
  @initial = initial
  @blk = blk
  reset_memo
  super(elem_name, bud_instance, collection_name, schema)
end

Public Instance Methods

flush() click to toggle source
# File lib/bud/executor/elements.rb, line 528
def flush
  unless @memo.kind_of? Enumerable
    raise Bud::TypeError, "output of reduce must be Enumerable: #{@memo.inspect}"
  end
  @memo.each do |t|
    push_out(t, false)
  end
end
insert(i, source=nil) click to toggle source
# File lib/bud/executor/elements.rb, line 514
def insert(i, source=nil)
  @memo = @blk.call(@memo, i)
end
invalidate_cache() click to toggle source
# File lib/bud/executor/elements.rb, line 518
def invalidate_cache
  puts "#{self.class}/#{self.tabname} invalidated" if $BUD_DEBUG
  reset_memo
end
reset_memo() click to toggle source
# File lib/bud/executor/elements.rb, line 523
def reset_memo
  @memo = Marshal.load(Marshal.dump(@initial))
end