Module: Duration::Numeric
- Included in:
- Numeric
- Defined in:
- lib/garcon/core_ext/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.
221 |
# File 'lib/garcon/core_ext/duration.rb', line 221 def days ; Duration[self * 86400] ; end |
#fortnights ⇒ Object Also known as: fortnight
Converts fortnights into seconds. (A fortnight is 2 weeks)
230 |
# File 'lib/garcon/core_ext/duration.rb', line 230 def fortnights ; Duration[self * 1209600] ; end |
#hours ⇒ Object Also known as: hour
Converts hours into seconds.
216 |
# File 'lib/garcon/core_ext/duration.rb', line 216 def hours ; Duration[self * 3600] ; end |
#minutes ⇒ Object Also known as: minute
Converts minutes into seconds.
212 |
# File 'lib/garcon/core_ext/duration.rb', line 212 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.
235 |
# File 'lib/garcon/core_ext/duration.rb', line 235 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.
208 |
# File 'lib/garcon/core_ext/duration.rb', line 208 def seconds ; Duration[self] ; end |