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()
Alias for: to_centuries
centuries=(number) click to toggle source
# File lib/timespan/units.rb, line 93
def centuries= number
        self.decades = number * 10
end
days()
Alias for: to_days
decades()
Alias for: to_decades
decades=(number) click to toggle source
# File lib/timespan/units.rb, line 89
def decades= number
        self.years = number * 10
end
hours()
Alias for: to_hours
hrs()
Alias for: to_hours
millis()
Alias for: to_mils
milliseconds()
Alias for: to_mils
mins()
Alias for: to_minutes
minutes()
Alias for: to_minutes
months()
Alias for: to_months
seconds() click to toggle source
# File lib/timespan/units.rb, line 10
def seconds
        @seconds     ||= duration.total
end
Also aliased as: to_secs, to_seconds, secs
secs()
Alias for: seconds
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_d()
Alias for: to_days
to_days() click to toggle source
# File lib/timespan/units.rb, line 34
def to_days
        @to_days ||= (to_hours / 24.0).round
end
Also aliased as: to_d, days
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_h()
Alias for: to_hours
to_hours() click to toggle source
# File lib/timespan/units.rb, line 26
def to_hours
        @to_hours ||= (to_minutes / 60.0).round
end
Also aliased as: to_h, to_hrs, hrs, hours
to_hrs()
Alias for: to_hours
to_m()
Alias for: to_minutes
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_mils()
Also aliased as: millis, milliseconds
Alias for: to_milliseconds
to_mins()
Alias for: to_minutes
to_minutes() click to toggle source
# File lib/timespan/units.rb, line 18
def to_minutes
        @to_minutes ||= (to_seconds / 60.0).round
end
Also aliased as: to_m, to_mins, mins, minutes
to_mon()
Alias for: to_months
to_months() click to toggle source
# File lib/timespan/units.rb, line 46
def to_months
        @to_months ||= (to_days / 30.0).round
end
Also aliased as: to_mon, months
to_seconds()
Alias for: seconds
to_secs()
Alias for: seconds
to_w()
Alias for: to_weeks
to_weeks() click to toggle source
# File lib/timespan/units.rb, line 40
def to_weeks
        @to_weeks ||= (to_days / 7.0).round
end
Also aliased as: to_w, weeks
to_y()
Alias for: to_years
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
Also aliased as: to_y, yrs, to_yrs, years
to_yrs()
Alias for: to_years
units() click to toggle source
# File lib/timespan/units.rb, line 78
def units
        Timespan::Units.units
end
weeks()
Alias for: to_weeks
years()
Alias for: to_years
yrs()
Alias for: to_years