Class: FluQ::Event

Inherits:
Hash
  • Object
show all
Defined in:
lib/fluq/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record = {}, timestamp = Time.now) ⇒ Event

Returns a new instance of Event.

Parameters:

  • record (Hash) (defaults to: {})

    the attribute pairs

  • timestamp (Integer) (defaults to: Time.now)

    the UNIX timestamp



8
9
10
11
12
13
# File 'lib/fluq/event.rb', line 8

def initialize(record = {}, timestamp = Time.now)
  @timestamp = timestamp.to_i
  @meta = {}
  super()
  update(record) if Hash === record
end

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



4
5
6
# File 'lib/fluq/event.rb', line 4

def meta
  @meta
end

#timestampObject

Returns the value of attribute timestamp.



3
4
5
# File 'lib/fluq/event.rb', line 3

def timestamp
  @timestamp
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Returns true if comparable.

Returns:

  • (Boolean)

    true if comparable



21
22
23
24
25
26
27
28
# File 'lib/fluq/event.rb', line 21

def ==(other)
  case other
  when FluQ::Event
    super && other.timestamp == timestamp
  else
    super
  end
end

#inspectString

Returns inspection.

Returns:

  • (String)

    inspection



32
33
34
# File 'lib/fluq/event.rb', line 32

def inspect
  "#<FluQ::Event(#{timestamp}) data:#{super} meta:#{meta.inspect}>"
end

#timeTime

Returns UTC time.

Returns:

  • (Time)

    UTC time



16
17
18
# File 'lib/fluq/event.rb', line 16

def time
  @time ||= Time.at(timestamp).utc
end