Class: Muon::Format
- Inherits:
-
Object
- Object
- Muon::Format
- Defined in:
- lib/muon/format.rb
Class Method Summary collapse
Class Method Details
.duration(seconds) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/muon/format.rb', line 3 def self.duration(seconds) seconds ||= 0 seconds = seconds.to_i minutes = seconds / 60 if minutes == 0 "#{seconds} seconds" else seconds = seconds % 60 hours = minutes / 60 if hours == 0 "#{minutes} minutes, #{seconds} seconds" else minutes = minutes % 60 "#{hours} hours, #{minutes} minutes, #{seconds} seconds" end end end |