Class: Kurchatov::Riemann::Event

Inherits:
Object
  • Object
show all
Includes:
Beefcake::Message
Defined in:
lib/kurchatov/riemann/event.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ Event

Returns a new instance of Event.



18
19
20
21
22
23
24
25
26
# File 'lib/kurchatov/riemann/event.rb', line 18

def initialize(hash = nil)
  if hash
    super(hash)
    self.metric = hash[:metric] if hash[:metric]
  else
    super
  end
  @time ||= Time.now.to_i
end

Instance Method Details

#metricObject



28
29
30
# File 'lib/kurchatov/riemann/event.rb', line 28

def metric
  metric_d || metric_sint64 || metric_f
end

#metric=(m) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/kurchatov/riemann/event.rb', line 32

def metric=(m)
  if Integer === m and (-(2**63)...2**63) === m
    self.metric_sint64 = m
    self.metric_f = m.to_f
  else
    self.metric_d = m.to_f
    self.metric_f = m.to_f
  end
end