Sha256: e0f8d46e2848157ec31658acf0959d730471d5564e29b72a44a85c516cc1a559

Contents?: true

Size: 317 Bytes

Versions: 12

Compression:

Stored size: 317 Bytes

Contents

module Metacrunch
  class Job::Buffer

    def initialize(size)
      @size = size
    end

    def buffer(data)
      storage << data
      flush if storage.count >= @size
    end

    def flush
      storage
    ensure
      @buffer = nil
    end

  private

    def storage
      @buffer ||= []
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
metacrunch-4.0.3 lib/metacrunch/job/buffer.rb
metacrunch-4.0.2 lib/metacrunch/job/buffer.rb
metacrunch-4.0.1 lib/metacrunch/job/buffer.rb
metacrunch-3.1.4 lib/metacrunch/job/buffer.rb
metacrunch-3.1.3 lib/metacrunch/job/buffer.rb
metacrunch-3.1.2 lib/metacrunch/job/buffer.rb
metacrunch-3.1.1 lib/metacrunch/job/buffer.rb
metacrunch-3.1.0 lib/metacrunch/job/buffer.rb
metacrunch-3.0.3 lib/metacrunch/job/buffer.rb
metacrunch-3.0.2 lib/metacrunch/job/buffer.rb
metacrunch-3.0.1 lib/metacrunch/job/buffer.rb
metacrunch-3.0.0 lib/metacrunch/job/buffer.rb