Class: WeatherData::Temperature::Base
- Inherits:
-
Object
- Object
- WeatherData::Temperature::Base
show all
- Includes:
- Comparable
- Defined in:
- lib/weather_data/temperature/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(deg) ⇒ Base
Returns a new instance of Base.
10
11
12
13
14
15
16
|
# File 'lib/weather_data/temperature/base.rb', line 10
def initialize(deg)
@degrees = if deg.is_a? Numeric
deg
else
to_self(deg).degrees
end
end
|
Instance Attribute Details
#degrees ⇒ Object
Returns the value of attribute degrees.
8
9
10
|
# File 'lib/weather_data/temperature/base.rb', line 8
def degrees
@degrees
end
|
Instance Method Details
#*(value) ⇒ Object
46
47
48
|
# File 'lib/weather_data/temperature/base.rb', line 46
def *(value)
self.class.new(value * degrees)
end
|
#+(value) ⇒ Object
38
39
40
|
# File 'lib/weather_data/temperature/base.rb', line 38
def +(value)
self.class.new(degrees + to_self(value).degrees)
end
|
#-(value) ⇒ Object
42
43
44
|
# File 'lib/weather_data/temperature/base.rb', line 42
def -(value)
-(-self + value)
end
|
#-@ ⇒ Object
30
31
32
|
# File 'lib/weather_data/temperature/base.rb', line 30
def -@
self.class.new(-degrees)
end
|
#/(value) ⇒ Object
50
51
52
|
# File 'lib/weather_data/temperature/base.rb', line 50
def /(value)
self.class.new(value * (1 / degrees))
end
|
#<=>(value) ⇒ Object
34
35
36
|
# File 'lib/weather_data/temperature/base.rb', line 34
def <=>(value)
degrees <=> to_self(value).degrees
end
|
#==(value) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/weather_data/temperature/base.rb', line 18
def ==(value)
if value.is_a? Numeric
degrees == value
else
super
end
end
|
#to_f ⇒ Object
58
59
60
|
# File 'lib/weather_data/temperature/base.rb', line 58
def to_f
degrees
end
|
#to_i ⇒ Object
54
55
56
|
# File 'lib/weather_data/temperature/base.rb', line 54
def to_i
degrees.round
end
|