Class: SecondsToHhmmss

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

Class Method Summary collapse

Class Method Details

.format(seconds) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/seconds_to_hhmmss.rb', line 2

def self.format(seconds)
  hours = seconds / 3600
  minutes = (seconds / 60) % 60
  seconds = seconds % 60
  [hours, minutes, seconds].map do |item| 
    item.to_s.rjust(2,'0')
  end.join(':')
end