Module: Duration::Numeric

Included in:
Numeric
Defined in:
lib/garcon/core_ext/duration.rb

Overview

Numeric Extensions for Durations

Instance Method Summary collapse

Instance Method Details

#daysObject Also known as: day

Converts days into seconds.



221
# File 'lib/garcon/core_ext/duration.rb', line 221

def days ; Duration[self * 86400] ; end

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

#hoursObject Also known as: hour

Converts hours into seconds.



216
# File 'lib/garcon/core_ext/duration.rb', line 216

def hours ; Duration[self * 3600] ; end

#minutesObject Also known as: minute

Converts minutes into seconds.



212
# File 'lib/garcon/core_ext/duration.rb', line 212

def minutes ; Duration[self * 60] ; end

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

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

#weeksObject Also known as: week

Converts weeks into seconds.



225
# File 'lib/garcon/core_ext/duration.rb', line 225

def weeks ; Duration[self * 604800] ; end

#yearsObject Also known as: year

Converts years into seconds. WARNING: This is not exact as it assumes 365 days to a year.

ie. It doesn not account for leap years.


241
# File 'lib/garcon/core_ext/duration.rb', line 241

def years ; Duration[self * 365 * 86400, :years] ; end