Class: XSPF::Tracklist
Constant Summary
Constants inherited from Playlist
Playlist::ANNOTATION_RDOC, Playlist::ATTRIBUTES, Playlist::ATTRIBUTE_AND_ELEMENT, Playlist::ATTRIBUTION_CHILD_ELEMENTS, Playlist::ATTRIBUTION_RDOC, Playlist::CREATOR_RDOC, Playlist::DATE_RDOC, Playlist::ELEMENTS, Playlist::EXTENSION_CHILD_ELEMENTS, Playlist::EXTENSION_RDOC, Playlist::IDENTIFIER_RDOC, Playlist::IMAGE_RDOC, Playlist::INFO_RDOC, Playlist::LICENSE_RDOC, Playlist::LINK_CONTENT_RDOC, Playlist::LINK_REL_RDOC, Playlist::LOCATION_RDOC, Playlist::META_CONTENT_RDOC, Playlist::META_REL_RDOC, Playlist::TITLE_RDOC, Playlist::VERSION_DEFAULT, Playlist::VERSION_RDOC, Playlist::XMLNS_DEFAULT, Playlist::XMLNS_RDOC
Constants inherited from XSPF
ATTRIBUTES, ENCODING_RDOC, HTML_RDOC, M3U_RDOC, OUTPUT_FORMATS, RDF_RDOC, SMIL_RDOC, SOUNDBLOX_RDOC, VERSION_RDOC
Instance Attribute Summary collapse
-
#tracklist ⇒ Object
readonly
Returns the value of attribute tracklist.
Attributes inherited from Playlist
Attributes inherited from XSPF
Instance Method Summary collapse
-
#<<(track) ⇒ Object
Adds a new XSPF::Track to the XSPF::Tracklist.
-
#initialize(playlist = nil) ⇒ Tracklist
constructor
Creates a XSPF::Tracklist from a XSPF::Playlist (parse mode) or without parameters (generation mode).
-
#to_xml ⇒ Object
Exports the XSPF::Tracklist to XML (only the <trackList> section).
-
#tracks ⇒ Object
Returns an array XSPF::Track objects.
Methods inherited from Playlist
Methods inherited from XSPF
Constructor Details
#initialize(playlist = nil) ⇒ Tracklist
Creates a XSPF::Tracklist from a XSPF::Playlist (parse mode) or without parameters (generation mode)
357 358 359 360 361 362 363 364 365 |
# File 'lib/xspf.rb', line 357 def initialize(playlist=nil) if (playlist.instance_of?(Hash) || playlist.nil?) then @tracklist = '' @tracks = [] else @tracklist = playlist.tracklist_xml @tracks = @tracklist.elements.collect { |track| XSPF::Track.new(track) } end end |
Instance Attribute Details
#tracklist ⇒ Object (readonly)
Returns the value of attribute tracklist.
354 355 356 |
# File 'lib/xspf.rb', line 354 def tracklist @tracklist end |
Instance Method Details
#<<(track) ⇒ Object
Adds a new XSPF::Track to the XSPF::Tracklist
373 374 375 |
# File 'lib/xspf.rb', line 373 def <<(track) @tracks << track end |
#to_xml ⇒ Object
Exports the XSPF::Tracklist to XML (only the <trackList> section)
378 379 380 381 382 |
# File 'lib/xspf.rb', line 378 def to_xml xml = REXML::Element.new('trackList') @tracks.each { |t| xml << REXML::Document.new(t.to_xml) } xml.to_s end |
#tracks ⇒ Object
Returns an array XSPF::Track objects
368 369 370 |
# File 'lib/xspf.rb', line 368 def tracks @tracks end |