Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/kimurai/core_ext/numeric.rb

Instance Method Summary collapse

Instance Method Details

#durationObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/kimurai/core_ext/numeric.rb', line 3

def duration
  secs  = self.to_int
  mins  = secs / 60
  hours = mins / 60
  days  = hours / 24

  if days > 0
    "#{days}d, #{hours % 24}h"
  elsif hours > 0
    "#{hours}h, #{mins % 60}m"
  elsif mins > 0
    "#{mins}m, #{secs % 60}s"
  elsif secs >= 0
    "#{secs}s"
  end
end