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



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?



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



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

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

#timeTime



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

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