module Time::Units
Constants
- PER_DAY
- PER_HOUR
- PER_MICROSECOND
- PER_MILLISECOND
- PER_MINUTE
Public Instance Methods
days()
click to toggle source
# File lib/familia/core_ext.rb, line 54 def days() seconds * PER_DAY end
Also aliased as: day
hours()
click to toggle source
# File lib/familia/core_ext.rb, line 53 def hours() seconds * PER_HOUR end
Also aliased as: hour
in_days()
click to toggle source
# File lib/familia/core_ext.rb, line 60 def in_days() seconds / PER_DAY end
in_hours()
click to toggle source
# File lib/familia/core_ext.rb, line 61 def in_hours() seconds / PER_HOUR end
in_microseconds()
click to toggle source
# File lib/familia/core_ext.rb, line 64 def in_microseconds() seconds / PER_MICROSECOND end
in_milliseconds()
click to toggle source
# File lib/familia/core_ext.rb, line 63 def in_milliseconds() seconds / PER_MILLISECOND end
in_minutes()
click to toggle source
# File lib/familia/core_ext.rb, line 62 def in_minutes() seconds / PER_MINUTE end
in_seconds(u=nil)
click to toggle source
# File lib/familia/core_ext.rb, line 70 def in_seconds(u=nil) case u.to_s when /\A(y)|(years?)\z/ years when /\A(w)|(weeks?)\z/ weeks when /\A(d)|(days?)\z/ days when /\A(h)|(hours?)\z/ hours when /\A(m)|(minutes?)\z/ minutes when /\A(ms)|(milliseconds?)\z/ milliseconds when /\A(us)|(microseconds?)|(μs)\z/ microseconds else self end end
in_time()
click to toggle source
# File lib/familia/core_ext.rb, line 66 def in_time Time.at(self).utc end
in_weeks()
click to toggle source
# File lib/familia/core_ext.rb, line 59 def in_weeks() seconds / PER_DAY / 7 end
in_years()
click to toggle source
# File lib/familia/core_ext.rb, line 58 def in_years() seconds / PER_DAY / 365 end
microseconds()
click to toggle source
# File lib/familia/core_ext.rb, line 49 def microseconds() seconds * PER_MICROSECOND end
Also aliased as: 'μs'
milliseconds()
click to toggle source
# File lib/familia/core_ext.rb, line 50 def milliseconds() seconds * PER_MILLISECOND end
Also aliased as: ms
minutes()
click to toggle source
# File lib/familia/core_ext.rb, line 52 def minutes() seconds * PER_MINUTE end
Also aliased as: minute
ms()
JRuby doesn't like using instance_methods.select here. It could be a bug or something quirky with Attic (although it works in 1.8 and 1.9). The error: lib/attic.rb:32:in `select': yield called out of block (LocalJumpError) lib/stella/mixins/numeric.rb:24 Create singular methods, like hour and day.
instance_methods.select.each do |plural|
singular = plural.to_s.chop alias_method singular, plural
end
Alias for: milliseconds
seconds()
click to toggle source
# File lib/familia/core_ext.rb, line 51 def seconds() self end
Also aliased as: second
weeks()
click to toggle source
# File lib/familia/core_ext.rb, line 55 def weeks() seconds * PER_DAY * 7 end
Also aliased as: week
years()
click to toggle source
# File lib/familia/core_ext.rb, line 56 def years() seconds * PER_DAY * 365 end
Also aliased as: year