module Timespan::Units
Public Class Methods
duration_units()
click to toggle source
# File lib/timespan/units.rb, line 70 def self.duration_units %w{seconds minutes hours days weeks months years} end
units()
click to toggle source
# File lib/timespan/units.rb, line 74 def self.units duration_units + %w{decades centuries} end
Public Instance Methods
centuries=(number)
click to toggle source
# File lib/timespan/units.rb, line 93 def centuries= number self.decades = number * 10 end
decades=(number)
click to toggle source
# File lib/timespan/units.rb, line 89 def decades= number self.years = number * 10 end
seconds()
click to toggle source
# File lib/timespan/units.rb, line 10 def seconds @seconds ||= duration.total end
to_centuries()
click to toggle source
# File lib/timespan/units.rb, line 65 def to_centuries @to_centuries ||= (to_decades / 10.0).round end
Also aliased as: centuries
to_days()
click to toggle source
# File lib/timespan/units.rb, line 34 def to_days @to_days ||= (to_hours / 24.0).round end
to_decades()
click to toggle source
# File lib/timespan/units.rb, line 60 def to_decades @to_decades ||= (to_years / 10.0).round end
Also aliased as: decades
to_hours()
click to toggle source
# File lib/timespan/units.rb, line 26 def to_hours @to_hours ||= (to_minutes / 60.0).round end
to_milliseconds()
click to toggle source
# File lib/timespan/units.rb, line 3 def to_milliseconds @to_seconds ||= (seconds * 1000.0).round end
Also aliased as: to_mils
to_minutes()
click to toggle source
# File lib/timespan/units.rb, line 18 def to_minutes @to_minutes ||= (to_seconds / 60.0).round end
to_months()
click to toggle source
# File lib/timespan/units.rb, line 46 def to_months @to_months ||= (to_days / 30.0).round end
to_weeks()
click to toggle source
# File lib/timespan/units.rb, line 40 def to_weeks @to_weeks ||= (to_days / 7.0).round end
to_years()
click to toggle source
# File lib/timespan/units.rb, line 52 def to_years @to_years ||= (to_days.to_f / 365.25).round end
units()
click to toggle source
# File lib/timespan/units.rb, line 78 def units Timespan::Units.units end