class DmmUtil::Reading
Constants
- MULTIPLIER_MAP
Attributes
raw[R]
Public Class Methods
new(attrs)
click to toggle source
# File lib/dmm_util/reading.rb, line 21 def initialize(attrs) @raw = attrs end
Public Instance Methods
==(other)
click to toggle source
# File lib/dmm_util/reading.rb, line 58 def ==(other) value == other.value && unit == other.unit end
scaled_value()
click to toggle source
# File lib/dmm_util/reading.rb, line 37 def scaled_value decimals = @raw[:decimals] multiplier = @raw[:unit_multiplier] state = @raw[:state] if state == "NORMAL" val = "%.#{decimals}f" % (value / (10 ** multiplier)) elsif state == "OL_MINUS" val = "-OL" else val = state end [val, "#{MULTIPLIER_MAP[multiplier]}#{unit}"] end
to_s()
click to toggle source
# File lib/dmm_util/reading.rb, line 53 def to_s sv = scaled_value "#{sv.first} #{sv.last}" end
ts()
click to toggle source
# File lib/dmm_util/reading.rb, line 25 def ts raw[:ts] end
unit()
click to toggle source
# File lib/dmm_util/reading.rb, line 33 def unit raw[:unit] end
value()
click to toggle source
# File lib/dmm_util/reading.rb, line 29 def value raw[:value] end