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.



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

def days ; Duration[self * 86400] ; end

#fortnightsObject Also known as: fortnight

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



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

def fortnights ; Duration[self * 1209600] ; end

#hoursObject Also known as: hour

Converts hours into seconds.



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

def hours ; Duration[self * 3600] ; end

#minutesObject Also known as: minute

Converts minutes into seconds.



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

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.



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

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.



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

def seconds ; Duration[self] ; end

#weeksObject Also known as: week

Converts weeks into seconds.



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

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.


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

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