Class: TrelloLeadTime::TimeHumanizer

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

Class Method Summary collapse

Class Method Details

.humanize_seconds(seconds) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/trello_lead_time/time_humanizer.rb', line 3

def self.humanize_seconds(seconds)
  [[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].inject([]){ |s, (count, name)|
    if seconds > 0
      seconds, n = seconds.divmod(count)
      s.unshift "#{n.to_i} #{name}"
    end
    s
  }.join(' ')
end