Sha256: 6c8da819c5c2c8c461d6571d46f34738684d4250e441bea2dcc34a38d22a65f7

Contents?: true

Size: 839 Bytes

Versions: 2

Compression:

Stored size: 839 Bytes

Contents

class FluQ::Format::Base
  include FluQ::Mixins::Loggable
  extend FluQ::Mixins::Loggable

  # @abstract converter
  # @param [String] raw event string
  # @return [FluQ::Event] event
  def self.to_event(raw)
  end

  # @abstract initializer
  # @param [Hash] options format-specific options
  def initialize(options = {})
    @options = options
  end

  # @abstract parse data, return events
  # @param [String] data
  # @return [Array<FluQ::Event>] events
  def parse(data)
    events = []
    parse_each(data) do |raw|
      if event = self.class.to_event(raw)
        events.push(event)
        true
      else
        false
      end
    end
    events
  end

  protected

    # @abstract enumerator
    # @param [String] data
    # @yield over raw events
    # @yieldparam [Hash] raw event data
    def parse_each(data)
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

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