module Time::Units

Constants

PER_DAY
PER_HOUR
PER_MICROSECOND
PER_MILLISECOND
PER_MINUTE

Public Instance Methods

'μs'()
Alias for: microseconds
day()
Alias for: days
days() click to toggle source
# File lib/stella/core_ext.rb, line 186
def days()            seconds * PER_DAY               end
Also aliased as: day
hour()
Alias for: hours
hours() click to toggle source
# File lib/stella/core_ext.rb, line 185
def hours()           seconds * PER_HOUR             end
Also aliased as: hour
in_days() click to toggle source
# File lib/stella/core_ext.rb, line 192
def in_days()         seconds / PER_DAY          end
in_hours() click to toggle source
# File lib/stella/core_ext.rb, line 193
def in_hours()        seconds / PER_HOUR          end
in_microseconds() click to toggle source
# File lib/stella/core_ext.rb, line 196
def in_microseconds() seconds / PER_MICROSECOND   end
in_milliseconds() click to toggle source
# File lib/stella/core_ext.rb, line 195
def in_milliseconds() seconds / PER_MILLISECOND    end
in_minutes() click to toggle source
# File lib/stella/core_ext.rb, line 194
def in_minutes()      seconds / PER_MINUTE         end
in_seconds(u=nil) click to toggle source
# File lib/stella/core_ext.rb, line 202
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/stella/core_ext.rb, line 198
def in_time
  Time.at(self).utc
end
in_weeks() click to toggle source
# File lib/stella/core_ext.rb, line 191
def in_weeks()        seconds / PER_DAY / 7       end
in_years() click to toggle source
# File lib/stella/core_ext.rb, line 190
def in_years()        seconds / PER_DAY / 365      end
microseconds() click to toggle source
# File lib/stella/core_ext.rb, line 181
def microseconds()    seconds * PER_MICROSECOND     end
Also aliased as: 'μs'
milliseconds() click to toggle source
# File lib/stella/core_ext.rb, line 182
def milliseconds()    seconds * PER_MILLISECOND    end
Also aliased as: ms
minute()
Alias for: minutes
minutes() click to toggle source
# File lib/stella/core_ext.rb, line 184
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
second()
Alias for: seconds
seconds() click to toggle source
# File lib/stella/core_ext.rb, line 183
def seconds()         self                         end
Also aliased as: second
week()
Alias for: weeks
weeks() click to toggle source
# File lib/stella/core_ext.rb, line 187
def weeks()           seconds * PER_DAY * 7           end
Also aliased as: week
year()
Alias for: years
years() click to toggle source
# File lib/stella/core_ext.rb, line 188
def years()           seconds * PER_DAY * 365        end
Also aliased as: year