Class: Kwh
- Inherits:
-
Object
- Object
- Kwh
- Defined in:
- lib/p1_meter_reader/kwh.rb
Instance Method Summary collapse
- #-(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(value) ⇒ Kwh
constructor
A new instance of Kwh.
- #inspect ⇒ Object
- #to_f ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ Kwh
Returns a new instance of Kwh.
10 11 12 |
# File 'lib/p1_meter_reader/kwh.rb', line 10 def initialize(value) self.value = value end |
Instance Method Details
#-(other) ⇒ Object
22 23 24 |
# File 'lib/p1_meter_reader/kwh.rb', line 22 def -(other) kWh(self.value - other.value) end |
#==(other) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/p1_meter_reader/kwh.rb', line 14 def ==(other) if other.is_a?(Kwh) return (self - other).value.abs < 0.001 end false end |
#inspect ⇒ Object
26 27 28 |
# File 'lib/p1_meter_reader/kwh.rb', line 26 def inspect "#{value}kWh" end |
#to_f ⇒ Object
34 35 36 |
# File 'lib/p1_meter_reader/kwh.rb', line 34 def to_f value end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/p1_meter_reader/kwh.rb', line 30 def to_s inspect end |