Class: Barometer::Data::ConvertableUnits
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Barometer::Data::ConvertableUnits
show all
- Includes:
- Comparable
- Defined in:
- lib/barometer/data/convertable_units.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ConvertableUnits.
8
9
10
11
12
13
|
# File 'lib/barometer/data/convertable_units.rb', line 8
def initialize(*args)
parse_metric!(args)
parse_values!(args)
super(magnitude)
freeze_all
end
|
Instance Method Details
#<=>(other) ⇒ Object
23
24
25
|
# File 'lib/barometer/data/convertable_units.rb', line 23
def <=>(other)
round(metric) <=> round(other.metric)
end
|
#imperial ⇒ Object
31
32
33
|
# File 'lib/barometer/data/convertable_units.rb', line 31
def imperial
@imperial_value || imperial_from_metric
end
|
#metric ⇒ Object
27
28
29
|
# File 'lib/barometer/data/convertable_units.rb', line 27
def metric
@metric_value || metric_from_imperial
end
|
#metric? ⇒ Boolean
39
40
41
|
# File 'lib/barometer/data/convertable_units.rb', line 39
def metric?
!!@metric
end
|
#nil? ⇒ Boolean
19
20
21
|
# File 'lib/barometer/data/convertable_units.rb', line 19
def nil?
magnitude.nil?
end
|
#to_s ⇒ Object
15
16
17
|
# File 'lib/barometer/data/convertable_units.rb', line 15
def to_s
magnitude_to_s
end
|
#units ⇒ Object
35
36
37
|
# File 'lib/barometer/data/convertable_units.rb', line 35
def units
metric? ? 'METRIC' : 'IMPERIAL'
end
|