Class: PlaylistCreator
- Inherits:
-
Object
- Object
- PlaylistCreator
- Defined in:
- lib/playlist_creator.rb
Instance Method Summary collapse
- #add(title: '', location: '') ⇒ Object
- #delete(id) ⇒ Object
-
#initialize(obj) ⇒ PlaylistCreator
constructor
A new instance of PlaylistCreator.
- #to_xml ⇒ Object
- #to_xspf ⇒ Object
Constructor Details
#initialize(obj) ⇒ PlaylistCreator
Returns a new instance of PlaylistCreator.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/playlist_creator.rb', line 38 def initialize(obj) @dx = if obj.is_a? String then header = "<?dynarex schema='tracklist/track(title, location)'?>\n--+\n" Dynarex.new(header + obj) elsif obj.is_a? Dynarex obj end end |
Instance Method Details
#add(title: '', location: '') ⇒ Object
49 50 51 |
# File 'lib/playlist_creator.rb', line 49 def add(title: '', location: '') @dx.create({title: title, location: location}) end |
#delete(id) ⇒ Object
53 54 55 |
# File 'lib/playlist_creator.rb', line 53 def delete(id) @dx.delete id end |
#to_xml ⇒ Object
57 58 59 |
# File 'lib/playlist_creator.rb', line 57 def to_xml() @dx.to_xml pretty: true end |
#to_xspf ⇒ Object
61 62 63 64 65 |
# File 'lib/playlist_creator.rb', line 61 def to_xspf() doc = Nokogiri::XML(@dx.to_xml(pretty: true)) xslt = Nokogiri::XSLT(XSLT_DX) xslt.transform(doc).to_xml end |