Sha256: 772a3b586b63221cfeff63448b21c57ff8e3b073370f7434888a5ae76e9949ff
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
require "oga" module Traktor module NML class Playlist include Enumerable attr_reader :tracks def initialize(node, collection) @tracks = (find_playlist node).first.xpath('PLAYLIST/ENTRY/PRIMARYKEY').map do |track| collection.track_from_primarykey track.attribute('KEY').text end.compact end def length @tracks.length end alias_method :size, :length def each @tracks.each do |track| yield track end end def [](i) @tracks[i] end private def find_playlist(node) node.each do |nd| nd.xpath('NODE/SUBNODES').each do |elm| if elm.xpath('NODE').size == 0 return nil elsif elm.xpath('NODE[@TYPE="PLAYLIST"]').size > 0 return elm.xpath('NODE[@TYPE="PLAYLIST"]') else return find_playlist elm.xpath('NODE/SUBNODES/NODE') end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
traktor-nml-0.3.1 | lib/traktor/nml/playlist.rb |
traktor-nml-0.3.0 | lib/traktor/nml/playlist.rb |