Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/redpomo/numeric_ext.rb

Defined Under Namespace

Modules: Units

Instance Method Summary collapse

Instance Method Details

#seconds_in_wordsObject



16
17
18
19
20
21
22
# File 'lib/redpomo/numeric_ext.rb', line 16

def seconds_in_words
  return "0 secs" if self.zero?
  unit = get_unit(self)
  unit_difference = self / Units.const_get(unit.capitalize)
  unit = unit.to_s.downcase + ('s' if self > 1)
  "#{unit_difference.to_i} #{unit}"
end