lib/dvd_title.rb
# Parse the @duration string into an integer number of seconds
Parse the @duration string into an integer number of seconds
Parse the @duration string into an integer number of seconds
def duration_seconds
    return 0 if @duration.nil? 
    tokens = @duration.split(':')
    seconds = tokens[-1].to_i
    if tokens.length > 1
      seconds = seconds + (tokens[-2].to_i * 60)
    end
    if tokens.length > 2
      seconds = seconds + (tokens[-3].to_i * 60 * 60)
    end
    return seconds
  end
def duration_seconds return 0 if @duration . nil? tokens = @duration . split ( ':' ) seconds = tokens [ - 1 ] . to_i if tokens . length > 1 seconds = seconds + ( tokens [ - 2 ] . to_i * 60 ) end if tokens . length > 2 seconds = seconds + ( tokens [ - 3 ] . to_i * 60 * 60 ) end return seconds end
Parse the @duration string into an integer number of seconds
Parse the @duration string into an integer number of seconds
# Initialize with the least significant digits # Add the minutes digit, if present # Add the hours digit, if present