Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/mergetrain_check/formatter.rb
Instance Method Summary collapse
Instance Method Details
#duration ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/mergetrain_check/formatter.rb', line 86 def duration rest, secs = self.divmod( 60 ) # self is the time difference t2 - t1 rest, mins = rest.divmod( 60 ) days, hours = rest.divmod( 24 ) result = [] result << "#{days}D " if days > 0 result << "#{hours}h" if hours > 0 result << "#{mins}m" if mins > 0 result << "#{secs.to_i}s" if secs.to_i > 0 return result.join(' ') end |