Class: TimeDiff

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/rvc/util.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(str) ⇒ Object



333
334
335
336
337
338
339
# File 'lib/rvc/util.rb', line 333

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_sObject



323
324
325
326
327
328
329
330
331
# File 'lib/rvc/util.rb', line 323

def to_s
  i = self.to_i
  seconds = i % 60
  i /= 60
  minutes = i % 60
  i /= 60
  hours = i
  [hours, minutes, seconds].join ':'
end