Module: RichUnits::Duration::Numeric
- Included in:
- Numeric
- Defined in:
- lib/richunits/duration.rb
Overview
Numeric Extensions for Durations
Instance Method Summary collapse
-
#days ⇒ Object
(also: #day)
Converts days into seconds.
-
#fortnights ⇒ Object
(also: #fortnight)
Converts fortnights into seconds.
-
#hours ⇒ Object
(also: #hour)
Converts hours into seconds.
-
#minutes ⇒ Object
(also: #minute)
Converts minutes into seconds.
-
#months ⇒ Object
(also: #month)
Converts months into seconds.
-
#seconds ⇒ Object
(also: #second)
Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
-
#weeks ⇒ Object
(also: #week)
Converts weeks into seconds.
-
#years ⇒ Object
(also: #year)
Converts years into seconds.
Instance Method Details
#days ⇒ Object Also known as: day
Converts days into seconds.
253 |
# File 'lib/richunits/duration.rb', line 253 def days ; Duration[self * 86400] ; end |
#fortnights ⇒ Object Also known as: fortnight
Converts fortnights into seconds. (A fortnight is 2 weeks)
262 |
# File 'lib/richunits/duration.rb', line 262 def fortnights ; Duration[self * 1209600] ; end |
#hours ⇒ Object Also known as: hour
Converts hours into seconds.
248 |
# File 'lib/richunits/duration.rb', line 248 def hours ; Duration[self * 3600] ; end |
#minutes ⇒ Object Also known as: minute
Converts minutes into seconds.
244 |
# File 'lib/richunits/duration.rb', line 244 def minutes ; Duration[self * 60] ; end |
#months ⇒ Object Also known as: month
Converts months into seconds. WARNING: This is not exact as it assumes 30 days to a month.
267 |
# File 'lib/richunits/duration.rb', line 267 def months ; Duration[self * 30 * 86400] ; end |
#seconds ⇒ Object Also known as: second
Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. The base unit for all of these Numeric time methods is seconds.
240 |
# File 'lib/richunits/duration.rb', line 240 def seconds ; Duration[self] ; end |
#weeks ⇒ Object Also known as: week
Converts weeks into seconds.
257 |
# File 'lib/richunits/duration.rb', line 257 def weeks ; Duration[self * 604800] ; end |
#years ⇒ Object Also known as: year
Converts years into seconds. WARNING: This is not exact as it assumes 365 days to a year.
ie. It doesn not account for leap years.
273 |
# File 'lib/richunits/duration.rb', line 273 def years ; Duration[self * 365 * 86400, :years] ; end |