Sha256: 3397353595461866a7277b68336c8be23a309b2c9a9450036de9be2ac101aa8c
Contents?: true
Size: 595 Bytes
Versions: 1
Compression:
Stored size: 595 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.presence ensure @buffer = [] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
metacrunch-4.2.0 | lib/metacrunch/job/buffer.rb |