Sha256: 9d6a97fe2eac98d8019e868d6df94de93789b925cf06d57deecb977129b088dd
Contents?: true
Size: 586 Bytes
Versions: 2
Compression:
Stored size: 586 Bytes
Contents
module Metacrunch class Job::Buffer def initialize(size_or_proc) @size_or_proc = size_or_proc @buffer = [] if @size_or_proc.is_a?(Numeric) && @size_or_proc <= 0 raise ArgumentError, "Buffer size must be a posive number greater that 0." end end def buffer(data) @buffer << data case @size_or_proc when Numeric flush if @buffer.count >= @size_or_proc.to_i when Proc flush if @size_or_proc.call == true end end def flush @buffer ensure @buffer = [] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
metacrunch-4.1.1 | lib/metacrunch/job/buffer.rb |
metacrunch-4.1.0 | lib/metacrunch/job/buffer.rb |