Class: Float

Inherits:
Object
  • Object
show all
Defined in:
lib/openhab/core_ext/ruby/numeric.rb

Overview

Extensions to Float

Instance Method Summary collapse

Instance Method Details

#daysDuration Also known as: day

Create Duration of ‘self` days

Returns:



113
114
115
# File 'lib/openhab/core_ext/ruby/numeric.rb', line 113

def days
  (self * 24).hours
end

#hoursDuration Also known as: hour

Create Duration of ‘self` hours

Returns:



103
104
105
# File 'lib/openhab/core_ext/ruby/numeric.rb', line 103

def hours
  (self * 60).minutes
end

#millisecondsDuration Also known as: millisecond, ms

Create Duration of ‘self` milliseconds

Returns:



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

#minutesDuration Also known as: minute

Create Duration of ‘self` minutes

Returns:



93
94
95
# File 'lib/openhab/core_ext/ruby/numeric.rb', line 93

def minutes
  (self * 60).seconds
end

#monthsDuration Also known as: month

Create Duration of ‘self` months

Returns:



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

#secondsDuration Also known as: second

Create Duration of ‘self` seconds

Returns:



83
84
85
# File 'lib/openhab/core_ext/ruby/numeric.rb', line 83

def seconds
  (self * 1000).milliseconds
end

#yearsDuration Also known as: year

Create Duration of ‘self` years

Returns:



133
134
135
# File 'lib/openhab/core_ext/ruby/numeric.rb', line 133

def years
  (self * java.time.temporal.ChronoUnit::YEARS.duration.to_i).seconds
end