Sha256: 0a66d97b4166e045efe9ed241a4eef19097ee2cf74210c0593dbb5f1a98ecb24

Contents?: true

Size: 864 Bytes

Versions: 4

Compression:

Stored size: 864 Bytes

Contents

class FluQ::Buffer::Base
  MAX_SIZE = 256 * 1024 * 1024 # 256M

  # @attr_reader [Hash] config
  attr_reader :config

  # @param [Hash] options various configuration options
  def initialize(options = {})
    super()
    @config = defaults.merge(options)
  end

  # @return [String] name identifier
  def name
    @name ||= self.class.name.split("::").last.downcase
  end

  # @abstract
  # @yield over io object
  # @yieldparam [IO] io
  def drain
    yield StringIO.new
  end

  # @abstract
  # @return [Integer] the size
  def size
    0
  end

  # @return [Boolean] true if size exceeds limit
  def full?
    size >= config[:max_size]
  end

  # @abstract data writer
  # @param [String] data binary string
  def write(data)
  end

  # @abstract callback, close buffer
  def close
  end

  protected

    def defaults
      { max_size: MAX_SIZE }
    end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fluq-0.7.5 lib/fluq/buffer/base.rb
fluq-0.7.3 lib/fluq/buffer/base.rb
fluq-0.7.1 lib/fluq/buffer/base.rb
fluq-0.7.0 lib/fluq/buffer/base.rb