class ITunes::XMLParser
Attributes
parsed[R]
Public Class Methods
new(params = {})
click to toggle source
# File lib/itunes/xml_parser.rb, line 14 def initialize(params = {}) @file_name = params[:file] parse if @file_name end
parse(xml, params = {})
click to toggle source
# File lib/itunes/xml_parser.rb, line 8 def self.parse(xml, params = {}) new(params.merge(:file => xml)) end
Public Instance Methods
add_path_to_track(id, track)
click to toggle source
# File lib/itunes/xml_parser.rb, line 45 def add_path_to_track(id, track) tracks[id]['Path'] = CGI.unescape(URI.parse(track['Location']).path) end
files()
click to toggle source
# File lib/itunes/xml_parser.rb, line 27 def files @files ||= begin _files = [ ] tracks.each do |id, track| _files << track.merge(:path_on_file_system => CGI.unescape(URI(track['Location']).path)) end _files end end
parse(params = {})
click to toggle source
# File lib/itunes/xml_parser.rb, line 19 def parse(params = {}) @parsed = Plist.parse_xml(@file_name) end
process_tracks(_tracks = @tracks)
click to toggle source
Performs additional processing to each tracks fields @param [Hash] _tracks
# File lib/itunes/xml_parser.rb, line 39 def process_tracks(_tracks = @tracks) _tracks.dup.each do |id, track| add_path_to_track(id, track) end end
tracks()
click to toggle source
# File lib/itunes/xml_parser.rb, line 23 def tracks @tracks ||= parsed['Tracks'] end