class ItunesParser::NokogiriSax::SaxDoc
Public Class Methods
new(on_track, on_playlist)
click to toggle source
Calls superclass method
# File vendor/itunes_parser/nokogiri_sax.rb, line 9 def initialize on_track, on_playlist super() @on_track, @on_playlist = on_track, on_playlist @with_callbacks = on_track || on_playlist @tracks, @playlists = [], [] unless @with_callbacks @buffer = "" end
Public Instance Methods
characters(string)
click to toggle source
# File vendor/itunes_parser/nokogiri_sax.rb, line 60 def characters(string) @buffer << string end
end_dict()
click to toggle source
# File vendor/itunes_parser/nokogiri_sax.rb, line 107 def end_dict if @parsing_playlists && !@parsing_playlist_items current = Hash[*@current] if !@with_callbacks @playlists.push(current) elsif @on_playlist @on_playlist.call(current) end @current = [] elsif @parsing_tracks if @current == [] end_tracks else current = Hash[*@current] if !@with_callbacks @tracks.push(current) elsif @on_track @on_track.call(current) end @current = [] end end end
end_element_namespace(name, *)
click to toggle source
def end_element(name)
# File vendor/itunes_parser/nokogiri_sax.rb, line 31 def end_element_namespace(name, *) case name when 'key' @key_string = @buffer.strip when 'dict' end_dict when 'array' if @parsing_playlist_items end_playlist_items elsif @parsing_playlists end_playlists end else if @parsing_playlist_items @current_playlist_items << @buffer.to_i elsif @parsing_playlists || @parsing_tracks if name == 'true' @current << @key_string << true elsif name == 'false' @current << @key_string << false else @current << @key_string << @buffer.strip end end end @buffer = "" end
end_playlist_items()
click to toggle source
# File vendor/itunes_parser/nokogiri_sax.rb, line 91 def end_playlist_items #puts " ** end playlist items" @parsing_playlist_items = false @current << "Playlist Items" @current << @current_playlist_items end
end_playlists()
click to toggle source
# File vendor/itunes_parser/nokogiri_sax.rb, line 81 def end_playlists @parsing_playlists = false end
end_tracks()
click to toggle source
# File vendor/itunes_parser/nokogiri_sax.rb, line 70 def end_tracks #puts " ** end tracks" @parsing_tracks = false end
error(error_message)
click to toggle source
# File vendor/itunes_parser/nokogiri_sax.rb, line 17 def error(error_message) raise error_message end
start_dict()
click to toggle source
# File vendor/itunes_parser/nokogiri_sax.rb, line 98 def start_dict case @key_string when "Tracks" start_tracks when "Playlists" start_playlists end end
start_element_namespace(name, *)
click to toggle source
def start_element(name, attrs = [])
# File vendor/itunes_parser/nokogiri_sax.rb, line 22 def start_element_namespace(name, *) case name when 'dict' ; start_dict when 'array' start_playlist_items if @key_string == 'Playlist Items' end end
start_playlist_items()
click to toggle source
# File vendor/itunes_parser/nokogiri_sax.rb, line 85 def start_playlist_items #puts " ** parsing playlist items" @current_playlist_items = [] @parsing_playlist_items = true end
start_playlists()
click to toggle source
# File vendor/itunes_parser/nokogiri_sax.rb, line 75 def start_playlists #puts " ** parsing playlists" @parsing_playlists = true @current = [] end
start_tracks()
click to toggle source
# File vendor/itunes_parser/nokogiri_sax.rb, line 64 def start_tracks #puts " ** parsing tracks" @parsing_tracks = true @current = [] end