Module: NumericMixable

Defined in:
lib/em-timers/numericmixable.rb

Overview

Stolen directly from ramaze/snippets

Instance Method Summary collapse

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

#daysObject 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

#hoursObject 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

#minutesObject 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

#monthsObject 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

#secondsObject Also known as: second



3
4
5
# File 'lib/em-timers/numericmixable.rb', line 3

def seconds
  self
end

#weeksObject 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

#yearsObject 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