Module: RichUnits::Duration::Numeric

Included in:
Numeric
Defined in:
lib/richunits/duration.rb

Overview

Numeric Extensions for Durations

Instance Method Summary collapse

Instance Method Details

#daysObject Also known as: day

Converts days into seconds.



253
# File 'lib/richunits/duration.rb', line 253

def days ; Duration[self * 86400] ; end

#fortnightsObject Also known as: fortnight

Converts fortnights into seconds. (A fortnight is 2 weeks)



262
# File 'lib/richunits/duration.rb', line 262

def fortnights ; Duration[self * 1209600] ; end

#hoursObject Also known as: hour

Converts hours into seconds.



248
# File 'lib/richunits/duration.rb', line 248

def hours ; Duration[self * 3600] ; end

#minutesObject Also known as: minute

Converts minutes into seconds.



244
# File 'lib/richunits/duration.rb', line 244

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.



267
# File 'lib/richunits/duration.rb', line 267

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.



240
# File 'lib/richunits/duration.rb', line 240

def seconds ; Duration[self] ; end

#weeksObject Also known as: week

Converts weeks into seconds.



257
# File 'lib/richunits/duration.rb', line 257

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.


273
# File 'lib/richunits/duration.rb', line 273

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