Class: Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/rearview/templates/monitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label_fn, timestamp, value) ⇒ Metric

Returns a new instance of Metric.



18
19
20
21
22
# File 'lib/rearview/templates/monitor.rb', line 18

def initialize(label_fn, timestamp, value)
  @label_fn  = label_fn
  @timestamp = timestamp
  @value     = value
end

Instance Attribute Details

#timestampObject (readonly)

Returns the value of attribute timestamp.



16
17
18
# File 'lib/rearview/templates/monitor.rb', line 16

def timestamp
  @timestamp
end

#valueObject (readonly)

Returns the value of attribute value.



16
17
18
# File 'lib/rearview/templates/monitor.rb', line 16

def value
  @value
end

Instance Method Details

#labelObject



24
25
26
# File 'lib/rearview/templates/monitor.rb', line 24

def label
  @label_fn.call
end

#to_sObject



28
29
30
# File 'lib/rearview/templates/monitor.rb', line 28

def to_s
  "{ label: #{label}, timestamp: #{timestamp}, value: #{value.nil? ? "nil" : value.to_f} }"
end