Class XSPF::Tracklist
In: lib/xspf.rb
Parent: XSPF::Playlist

Methods

<<   new   to_xml   tracks  

Attributes

tracklist  [R] 

Public Class methods

Creates a XSPF::Tracklist from a XSPF::Playlist (parse mode) or without parameters (generation mode)

[Source]

     # File lib/xspf.rb, line 348
348:   def initialize(playlist=nil)
349:     if (playlist.instance_of?(Hash) || playlist.nil?) then
350:       @tracklist = ''
351:       @tracks = []
352:     else
353:       @tracklist = playlist.tracklist_xml
354:       @tracks = @tracklist.elements.collect { |track| XSPF::Track.new(track) }
355:     end
356:   end

Public Instance methods

Adds a new XSPF::Track to the XSPF::Tracklist

[Source]

     # File lib/xspf.rb, line 364
364:   def <<(track)
365:     @tracks << track
366:   end

Exports the XSPF::Tracklist to XML (only the <trackList> section)

[Source]

     # File lib/xspf.rb, line 369
369:   def to_xml
370:     xml = REXML::Element.new('trackList')
371:     @tracks.each { |t| xml << REXML::Document.new(t.to_xml) }
372:     xml.to_s
373:   end

Returns an array XSPF::Track objects

[Source]

     # File lib/xspf.rb, line 359
359:   def tracks
360:     @tracks
361:   end

[Validate]