Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/videostore.rb

Instance Method Summary collapse

Instance Method Details

#youtube_duration_to_secondsObject



175
176
177
178
179
180
181
182
183
184
185
# File 'lib/videostore.rb', line 175

def youtube_duration_to_seconds
  hours =   match(/(\d+)H/)
  minutes = match(/(\d+)M/)
  seconds = match(/(\d+)S/)

  hours = hours     ? hours[1].to_i   : 0
  minutes = minutes ? minutes[1].to_i : 0
  seconds = seconds ? seconds[1].to_i : 0

  (hours * 3600) + (minutes * 60) + seconds
end