TimeDSL

Provides a a simple way of calling time units and to see the elapsed time between 2 moments

Examples

142.minutes => returns a value in seconds
7.days => returns a value in seconds
1.week => returns a value in seconds
2.weeks.ago => returns a date
1.year.since(time) => returns a date
5.months.since(2.weeks.from_now) => returns a date

Public Instance Methods

ago(time = ::Time.now) click to toggle source

Reads best without arguments: 10.minutes.ago

# File lib/merb-helpers/time_dsl.rb, line 47
def ago(time = ::Time.now)
  time - self
end
Also aliased as: until
day() click to toggle source
# File lib/merb-helpers/time_dsl.rb, line 26
def day
  self * 86400
end
Also aliased as: days
days() click to toggle source
Alias for: day
from_now(time = ::Time.now) click to toggle source
Alias for: since
hour() click to toggle source
# File lib/merb-helpers/time_dsl.rb, line 21
def hour
  self * 3600
end
Also aliased as: hours
hours() click to toggle source
Alias for: hour
minute() click to toggle source
# File lib/merb-helpers/time_dsl.rb, line 16
def minute
  self * 60
end
Also aliased as: minutes
minutes() click to toggle source
Alias for: minute
month() click to toggle source
# File lib/merb-helpers/time_dsl.rb, line 36
def month
  self * 2592000
end
Also aliased as: months
months() click to toggle source
Alias for: month
second() click to toggle source
# File lib/merb-helpers/time_dsl.rb, line 11
def second
  self * 1
end
Also aliased as: seconds
seconds() click to toggle source
Alias for: second
since(time = ::Time.now) click to toggle source

Reads best with argument: 10.minutes.since(time)

# File lib/merb-helpers/time_dsl.rb, line 53
def since(time = ::Time.now)
  time + self
end
Also aliased as: from_now
until(time = ::Time.now) click to toggle source
Alias for: ago
week() click to toggle source
# File lib/merb-helpers/time_dsl.rb, line 31
def week
  self * 604800
end
Also aliased as: weeks
weeks() click to toggle source
Alias for: week
year() click to toggle source
# File lib/merb-helpers/time_dsl.rb, line 41
def year
  self * 31471200
end
Also aliased as: years
years() click to toggle source
Alias for: year

[Validate]

Generated with the Darkfish Rdoc Generator 2.