class Numeric

Public Instance Methods

day()
Alias for: days
days() click to toggle source
# File lib/vendor/numeric_ext.rb, line 30
def days
  self * 24.hours
end
Also aliased as: day
hour()
Alias for: hours
hours() click to toggle source
# File lib/vendor/numeric_ext.rb, line 25
def hours
  self * 3600
end
Also aliased as: hour
minute()
Alias for: minutes
minutes() click to toggle source
# File lib/vendor/numeric_ext.rb, line 20
def minutes
  self * 60
end
Also aliased as: minute
month()
Alias for: months
months() click to toggle source
# File lib/vendor/numeric_ext.rb, line 40
def months
  self * 31.days
end
Also aliased as: month
second()
Alias for: seconds
seconds() click to toggle source

Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.

These methods use Time#advance for precise date calculations when using from_now, ago, etc. as well as adding or subtracting their results from a Time object. For example:

# equivalent to Time.current.advance(months: 1)
1.month.from_now

# equivalent to Time.current.advance(years: 2)
2.years.from_now

# equivalent to Time.current.advance(months: 4, years: 5)
(4.months + 5.years).from_now
# File lib/vendor/numeric_ext.rb, line 15
def seconds
  self
end
Also aliased as: second
week()
Alias for: weeks
weeks() click to toggle source
# File lib/vendor/numeric_ext.rb, line 35
def weeks
  self * 7.days
end
Also aliased as: week
year()
Alias for: years
years() click to toggle source
# File lib/vendor/numeric_ext.rb, line 45
def years
  self * 365.days
end
Also aliased as: year