Sha256: a5b7a38eb1108cd32643c0f195f9acb5aa34ce21953f57b066020d911ca274c2

Contents?: true

Size: 543 Bytes

Versions: 2

Compression:

Stored size: 543 Bytes

Contents

class FluQ::Format::Lines < FluQ::Format::Base
  include MonitorMixin

  # @see FluQ::Format::Base#initialize
  def initialize(*)
    super
    @buffer = ""
  end

  protected

    # @see FluQ::Format::Base#parse_each
    def parse_each(chunk)
      last_chunk = nil
      synchronize do
        @buffer << chunk
        @buffer.each_line do |line|
          line.chomp!
          next if line.empty?

          last_chunk = yield(line) ? nil : line
        end
        last_chunk ? @buffer = last_chunk : @buffer.clear
      end
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluq-0.8.1 lib/fluq/format/lines.rb
fluq-0.8.0 lib/fluq/format/lines.rb