Class: Numeric

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

Instance Method Summary collapse

Instance Method Details

#as_time(type = nil, min_s = " min", hr_s = " hrs") ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/printer.rb', line 18

def as_time(type = nil, min_s = " min", hr_s = " hrs")
    type = (self < 60) ? :minutes : :hours if !type
    if type == :minutes
        "#{self.round(0)}#{min_s}"
    else
        "#{(self/60.0).round(2)}#{hr_s}"
    end
end