Class: TimeDiff
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- TimeDiff
- Defined in:
- lib/rvc/util.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.parse(str) ⇒ Object
353 354 355 356 357 358 359 |
# File 'lib/rvc/util.rb', line 353 def self.parse str a = str.split(':', 3).reverse seconds = a[0].to_i rescue 0 minutes = a[1].to_i rescue 0 hours = a[2].to_i rescue 0 TimeDiff.new(hours * 3600 + minutes * 60 + seconds) end |
Instance Method Details
#to_s ⇒ Object
343 344 345 346 347 348 349 350 351 |
# File 'lib/rvc/util.rb', line 343 def to_s i = self.to_i seconds = i % 60 i /= 60 minutes = i % 60 i /= 60 hours = i [hours, minutes, seconds].join ':' end |