Sha256: 501f8d6b28e3a5e476d0aee2da7fbccb6cac1981fe0781b9a1abc7125fe28f0a

Contents?: true

Size: 726 Bytes

Versions: 2

Compression:

Stored size: 726 Bytes

Contents

class FluQ::Event < Hash

  attr_accessor :timestamp
  attr_reader :meta

  # @param [Hash] record the attribute pairs
  # @param [Integer] timestamp the UNIX timestamp
  def initialize(record = {}, timestamp = Time.now)
    @timestamp = timestamp.to_i
    @meta = {}
    super()
    update(record) if Hash === record
  end

  # @return [Time] UTC time
  def time
    @time ||= Time.at(timestamp).utc
  end

  # @return [Boolean] true if comparable
  def ==(other)
    case other
    when FluQ::Event
      super && other.timestamp == timestamp
    else
      super
    end
  end
  alias :eql? :==

  # @return [String] inspection
  def inspect
    "#<FluQ::Event(#{timestamp}) data:#{super} meta:#{meta.inspect}>"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluq-0.8.1 lib/fluq/event.rb
fluq-0.8.0 lib/fluq/event.rb