Sha256: 33473f7e361e97d95735a7616a31e9894248936da5d726956d7b7eee838949d7
Contents?: true
Size: 956 Bytes
Versions: 4
Compression:
Stored size: 956 Bytes
Contents
module Kagu class Tracks include Enumerable attr_reader :library def initialize(library) raise ArgumentError.new("#{self.class}#library must be a library, #{library.inspect} given") unless library.is_a?(Library) @library = library end def each(&block) return unless block_given? File.open(library.path, 'r') do |file| while !file.eof? && (line = file.readline.strip) next unless line.starts_with?('<key>Track ID</key>') attributes = {} begin match = line.match(/<key>(.+)<\/key><(\w+)>(.*)<\/\2>/) name = "itunes_#{match[1].downcase.gsub(' ', '_')}" value = match[3] attributes[name] = value end while (line = file.readline.strip) != '</dict>' yield(Track.new(attributes)) if attributes['itunes_track_type'] == 'File' && attributes['itunes_podcast'].blank? end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kagu-0.2.2 | lib/kagu/tracks.rb |
kagu-0.2.1 | lib/kagu/tracks.rb |
kagu-0.2.0 | lib/kagu/tracks.rb |
kagu-0.1.1 | lib/kagu/tracks.rb |