Sha256: a63de0bbdfd82f87c4a9888ae71c0fe0c494b75e158a79492029c0d5c31b4c68
Contents?: true
Size: 491 Bytes
Versions: 1
Compression:
Stored size: 491 Bytes
Contents
# frozen_string_literal: true module Pull class Collect DEFAULT_DONE_CALLBACK = -> () { puts "DONE" } def initialize(&block) @block = block @collection = [] end 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 private attr_reader :block end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pull_stream-1.0.0 | lib/pull/sink/collect.rb |