Class: Float
- Inherits:
-
Object
- Object
- Float
- Defined in:
- lib/openhab/core_ext/ruby/numeric.rb
Overview
Extensions to Float
Instance Method Summary collapse
-
#days ⇒ Duration
(also: #day)
Create Duration of
self
days. -
#hours ⇒ Duration
(also: #hour)
Create Duration of
self
hours. -
#milliseconds ⇒ Duration
(also: #millisecond, #ms)
Create Duration of
self
milliseconds. -
#minutes ⇒ Duration
(also: #minute)
Create Duration of
self
minutes. -
#months ⇒ Duration
(also: #month)
Create Duration of
self
months. -
#seconds ⇒ Duration
(also: #second)
Create Duration of
self
seconds. -
#years ⇒ Duration
(also: #year)
Create Duration of
self
years.
Instance Method Details
#days ⇒ Duration Also known as: day
Create Duration of self
days
113 114 115 |
# File 'lib/openhab/core_ext/ruby/numeric.rb', line 113 def days (self * 24).hours end |
#hours ⇒ Duration Also known as: hour
Create Duration of self
hours
103 104 105 |
# File 'lib/openhab/core_ext/ruby/numeric.rb', line 103 def hours (self * 60).minutes end |
#milliseconds ⇒ Duration Also known as: millisecond, ms
Create Duration of self
milliseconds
72 73 74 |
# File 'lib/openhab/core_ext/ruby/numeric.rb', line 72 def milliseconds java.time.Duration.of_nanos((self * 1_000_000).to_i) end |
#minutes ⇒ Duration Also known as: minute
Create Duration of self
minutes
93 94 95 |
# File 'lib/openhab/core_ext/ruby/numeric.rb', line 93 def minutes (self * 60).seconds end |
#months ⇒ Duration Also known as: month
Create Duration of self
months
123 124 125 |
# File 'lib/openhab/core_ext/ruby/numeric.rb', line 123 def months (self * java.time.temporal.ChronoUnit::MONTHS.duration.to_i).seconds end |