Class: Spectator::Measure
- Inherits:
-
Object
- Object
- Spectator::Measure
- Defined in:
- lib/spectator/measure.rb
Overview
This immutable class represents a measurement sampled from a meter
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compare this measurement against another one, taking into account nan values.
-
#initialize(id, value) ⇒ Measure
constructor
A meter id and a value.
-
#to_s ⇒ Object
A string representation of this measurement, for debugging purposes.
Constructor Details
#initialize(id, value) ⇒ Measure
A meter id and a value
7 8 9 10 |
# File 'lib/spectator/measure.rb', line 7 def initialize(id, value) @id = id @value = value.to_f end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/spectator/measure.rb', line 4 def id @id end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/spectator/measure.rb', line 4 def value @value end |
Instance Method Details
#==(other) ⇒ Object
Compare this measurement against another one, taking into account nan values
19 20 21 22 |
# File 'lib/spectator/measure.rb', line 19 def ==(other) @id == other.id && (@value == other.value || @value.nan? && other.value.nan?) end |
#to_s ⇒ Object
A string representation of this measurement, for debugging purposes
13 14 15 |
# File 'lib/spectator/measure.rb', line 13 def to_s "Measure{id=#{@id}, value=#{@value}}" end |