class Cuegrowler::Tracklist::ITunes

Public Instance Methods

get() click to toggle source
# File lib/cuegrowler.rb, line 25
def get
  parse_tracklist(Cuegrowler::ITunes.get_track_description)
end
to_s() click to toggle source
# File lib/cuegrowler.rb, line 29
def to_s
  "From iTunes description"
end

Protected Instance Methods

parse_tracklist(description) click to toggle source
# File lib/cuegrowler.rb, line 34
def parse_tracklist(description)
  description.lines.map(&:strip)
    .map { |line| [line, line.match(/\[(\d+):(\d+):(\d+)\]/)] }
    .reject { |text, match| match.nil? }
    .map { |text, match| { text: text, time: tracklist_match_to_time(match) } }
end
tracklist_match_to_time(m) click to toggle source
# File lib/cuegrowler.rb, line 41
def tracklist_match_to_time(m)
  m[1].to_f * 3600 + m[2].to_f * 60 + m[3].to_f
end