class PlaylistCreator
Public Class Methods
new(obj=nil)
click to toggle source
# File lib/playlist_creator.rb, line 41 def initialize(obj=nil) @dx = if obj.is_a? String then header = "<?dynarex schema='tracklist/track(location, title, " + "album)'?>\n--+\n" Dynarex.new(header + obj) elsif obj.is_a? Dynarex obj else Dynarex.new('tracklist/track(location, title, album)') end end
Public Instance Methods
add(titlex='', locationx='', title: titlex, location: locationx, album: '')
click to toggle source
# File lib/playlist_creator.rb, line 55 def add(titlex='', locationx='', title: titlex, location: locationx, album: '') @dx.create({title: title, location: location, album: album}) end
delete(id)
click to toggle source
# File lib/playlist_creator.rb, line 60 def delete(id) @dx.delete id end
find_by_title(title)
click to toggle source
# File lib/playlist_creator.rb, line 64 def find_by_title(title) @dx.all.select {|x| x.title[/#{title}/i]} end
to_dx()
click to toggle source
# File lib/playlist_creator.rb, line 68 def to_dx() @dx.clone end
to_xml()
click to toggle source
# File lib/playlist_creator.rb, line 72 def to_xml() @dx.to_xml pretty: true end
to_xspf()
click to toggle source
# File lib/playlist_creator.rb, line 76 def to_xspf() doc = Nokogiri::XML(@dx.to_xml(pretty: true)) xslt = Nokogiri::XSLT(XSLT_DX) xslt.transform(doc).to_xml end
update(id, title: nil, location: nil, album: nil)
click to toggle source
# File lib/playlist_creator.rb, line 82 def update(id, title: nil, location: nil, album: nil) @dx.update(id, {title: title, location: location, album: album}) end