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



246
247
248
249
250
251
252
# File 'lib/rvc/util.rb', line 246

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



236
237
238
239
240
241
242
243
244
# File 'lib/rvc/util.rb', line 236

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