class RecoverItunesRatings::SavedRatings

Enumerates the track ratings in an iTunes Library XML file.

Constants

IGNORED_TYPES

Public Class Methods

new(library_xml_path) click to toggle source
# File lib/recover_itunes_ratings/saved_ratings.rb, line 9
def initialize(library_xml_path)
  @path = library_xml_path
end

Public Instance Methods

each() { |data, to_i| ... } click to toggle source
# File lib/recover_itunes_ratings/saved_ratings.rb, line 13
def each
  parse on_track: ->(data) {
    next if data["Track Type"] == "Remote"
    next if IGNORED_TYPES.any?(&data.method(:has_key?))
    next if IGNORED_TYPES.any? { |t| data["Genre"] == t }

    yield data["Persistent ID"], data["Rating"].to_i
  }
end

Private Instance Methods

library() click to toggle source
# File lib/recover_itunes_ratings/saved_ratings.rb, line 23
        def library
  open(@path, "r")
end
parse(*args) click to toggle source
# File lib/recover_itunes_ratings/saved_ratings.rb, line 27
        def parse(*args)
  ::ItunesParser::NokogiriSax.new(library, *args).parse
end