Module: NumericMixable
- Defined in:
- lib/em-timers/numericmixable.rb
Overview
Stolen directly from ramaze/snippets
Instance Method Summary collapse
-
#ago(t = Time.now) ⇒ Object
(also: #before)
Time in the past, i.e.
-
#days ⇒ Object
(also: #day)
24 hours in a day.
-
#from_now(t = Time.now) ⇒ Object
(also: #since)
Time in the future, i.e.
-
#hours ⇒ Object
(also: #hour)
60 minutes in an hour.
-
#minutes ⇒ Object
(also: #minute)
60 seconds in a minute.
-
#months ⇒ Object
(also: #month)
30 days in a month.
- #seconds ⇒ Object (also: #second)
-
#weeks ⇒ Object
(also: #week)
7 days in a week.
-
#years ⇒ Object
(also: #year)
365.25 days in a year.
Instance Method Details
#ago(t = Time.now) ⇒ Object Also known as: before
Time in the past, i.e. 3.days.ago
45 46 47 |
# File 'lib/em-timers/numericmixable.rb', line 45 def ago t = Time.now t - self end |
#days ⇒ Object Also known as: day
24 hours in a day
21 22 23 |
# File 'lib/em-timers/numericmixable.rb', line 21 def days self * 86400 end |
#from_now(t = Time.now) ⇒ Object Also known as: since
Time in the future, i.e. 3.days.from_now
51 52 53 |
# File 'lib/em-timers/numericmixable.rb', line 51 def from_now t = Time.now t + self end |
#hours ⇒ Object Also known as: hour
60 minutes in an hour
15 16 17 |
# File 'lib/em-timers/numericmixable.rb', line 15 def hours self * 3600 end |
#minutes ⇒ Object Also known as: minute
60 seconds in a minute
9 10 11 |
# File 'lib/em-timers/numericmixable.rb', line 9 def minutes self * 60 end |
#months ⇒ Object Also known as: month
30 days in a month
33 34 35 |
# File 'lib/em-timers/numericmixable.rb', line 33 def months self * 2592000 end |
#seconds ⇒ Object Also known as: second
3 4 5 |
# File 'lib/em-timers/numericmixable.rb', line 3 def seconds self end |
#weeks ⇒ Object Also known as: week
7 days in a week
27 28 29 |
# File 'lib/em-timers/numericmixable.rb', line 27 def weeks self * 604800 end |
#years ⇒ Object Also known as: year
365.25 days in a year
39 40 41 |
# File 'lib/em-timers/numericmixable.rb', line 39 def years self * 883612800 end |