class XSPF # Version for the XML document or _nil_ if not defined def version; begin; @xspf.version; rescue NoMethodError; return nil; end; end end class XSPF # Encoding of the XML document or _nil_ if not defined def encoding; begin; @xspf.encoding; rescue NoMethodError; return nil; end; end end class XSPF # Creates a .m3u playlist from the XSPF document. This method makes use of the official XSPF to M3U XSLT transformation by Lucas Gonze. def to_m3u; xslt = XML::XSLT.new; xslt.xml = xspf; xslt.xsl = REXML::Document.new( File.new( './lib/xspf2m3u.xsl' ) ); xslt.serve; end end class XSPF # Outputs the playlist as an HTML page. This method makes use of the official XSPF to HTML XSLT transformation by Lucas Gonze. def to_html; xslt = XML::XSLT.new; xslt.xml = xspf; xslt.xsl = REXML::Document.new( File.new( './lib/xspf2html.xsl' ) ); xslt.serve; end end class XSPF # Creates a .smil playlist from the XSPF document. This method makes use of the official XSPF to SMIL XSLT transformation by Lucas Gonze. def to_smil; xslt = XML::XSLT.new; xslt.xml = xspf; xslt.xsl = REXML::Document.new( File.new( './lib/xspf2smil.xsl' ) ); xslt.serve; end end class XSPF # Creates a SoundBlox playlist from the XSPF document. This method makes use of the official XSPF to SoundBlox XSLT tranformation by Lucas Gonze. def to_soundblox; xslt = XML::XSLT.new; xslt.xml = xspf; xslt.xsl = REXML::Document.new( File.new( './lib/xspf2soundblox.xsl' ) ); xslt.serve; end end class XSPF::Playlist # The XML namespace. It must be http://xspf.org/ns/0/ for a valid XSPF document. def xmlns; begin; @playlist.root.attributes['xmlns']; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # The XSPF version. It may be 0 or 1, although 1 is strongly advised. def version; begin; @playlist.root.attributes['version']; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # A human-readable title for the playlist. xspf:playlist elements MAY contain exactly one. def title; begin; @playlist.elements['title'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # Human-readable name of the entity (author, authors, group, company, etc) that authored the playlist. XSPF::Playlist objects MAY contain exactly one. def creator; begin; @playlist.elements['creator'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # A human-readable comment on the playlist. This is character data, not HTML, and it may not contain markup. XSPF::Playlist objects elements MAY contain exactly one. def annotation; begin; @playlist.elements['annotation'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # URL of a web page to find out more about this playlist. Likely to be homepage of the author, and would be used to find out more about the author and to find more playlists by the author. XSPF::Playlist objects MAY contain exactly one. def info; begin; @playlist.elements['info'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # Source URL for this playlist. XSPF::Playlist objects MAY contain exactly one. def location; begin; @playlist.elements['location'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # Canonical ID for this playlist. Likely to be a hash or other location-independent name. MUST be a legal URN. XSPF::Playlist objects MAY contain exactly one. def identifier; begin; @playlist.elements['identifier'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # URL of an image to display if XSPF::Playlist#image return nil. XSPF::Playlist objects MAY contain exactly one. def image; begin; @playlist.elements['image'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # Creation date (not last-modified date) of the playlist, formatted as a XML schema dateTime. XSPF::Playlist objects MAY contain exactly one. def date; begin; @playlist.elements['date'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # URL of a resource that describes the license under which this playlist was released. XSPF::Playlist objects MAY contain zero or one license element. def license; begin; @playlist.elements['license'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # An ordered list of URIs. The purpose is to satisfy licenses allowing modification but requiring attribution. If you modify such a playlist, move its XSPF::Playlist#location or XSPF::Playlist#identifier element to the top of the items in the XSPF::Playlist#attribution element. XSPF::Playlist objects MAY contain exactly one attribution element. Please note that currently XSPF for Ruby does not parse the contents of XSPF::Playlist#attribution. def attribution; begin; @playlist.elements['attribution'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # The extension element allows non-XSPF XML to be included in XSPF documents without breaking XSPF validation. The purpose is to allow nested XML, which the meta and link elements do not. XSPF::Playlist objects MAY contain zero or more extension elements but currently XSPF for Ruby returns only the first one. def extension; begin; @playlist.elements['extension'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # The link element allows non-XSPF web resources to be included in XSPF documents without breaking XSPF validation. A valid 'link' element has a 'rel' attribute and a 'content' element, obtained with XSPF::Playlist#link_rel and XSPF::Playlist#link_content respectively. XSPF::Playlist objects MAY contain zero or more meta elements, but currently XSPF for Ruby returns only the first one. def link_content; begin; @playlist.elements['link'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # The link element allows non-XSPF web resources to be included in XSPF documents without breaking XSPF validation. A valid 'link' element has a 'rel' attribute and a 'content' element, obtained with XSPF::Playlist#link_rel and XSPF::Playlist#link_content respectively. XSPF::Playlist objects MAY contain zero or more link elements, but currently XSPF for Ruby returns only the first one. def link_rel; begin; @playlist.elements['link'].attributes['rel']; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # The meta element allows non-XSPF metadata to be included in XSPF documents without breaking XSPF validation. A valid 'meta' element has a 'rel' attribute and a 'content' element, obtained with XSPF::Playlist#meta_rel and XSPF::Playlist#meta_content respectively. XSPF::Playlist objects MAY contain zero or more meta elements, but currently XSPF for Ruby returns only the first one. def meta_content; begin; @playlist.elements['meta'].text; rescue NoMethodError; return nil; end; end end class XSPF::Playlist # The meta element allows non-XSPF metadata to be included in XSPF documents without breaking XSPF validation. A valid 'meta' element has a 'rel' attribute and a 'content' element, obtained with XSPF::Playlist#meta_rel and XSPF::Playlist#meta_content respectively. XSPF::Playlist objects MAY contain zero or more meta elements, but currently XSPF for Ruby returns only the first one. def meta_rel; begin; @playlist.elements['meta'].attributes['rel']; rescue NoMethodError; return nil; end; end end class XSPF::Track # URL of resource to be rendered. Probably an audio resource, but MAY be any type of resource with a well-known duration, such as video, a SMIL document, or an XSPF document. The duration of the resource defined in this element defines the duration of rendering. XSPF::Track objects MAY contain zero or more location elements, but a user-agent MUST NOT render more than one of the named resources. Currently, XSPF for Ruby returns only the first location. def location; begin; @track.elements['location'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # Canonical ID for this resource. Likely to be a hash or other location-independent name, such as a MusicBrainz identifier or isbn URN (if there existed isbn numbers for audio). MUST be a legal URN. XSPF::Track objects elements MAY contain zero or more identifier elements, but currently XSPF for Ruby returns only the first one. def identifier; begin; @track.elements['identifier'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # Human-readable name of the track that authored the resource which defines the duration of track rendering. This value is primarily for fuzzy lookups, though a user-agent may display it. XSPF::Track objects MAY contain exactly one. def title; begin; @track.elements['title'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # Human-readable name of the entity (author, authors, group, company, etc) that authored the resource which defines the duration of track rendering. This value is primarily for fuzzy lookups, though a user-agent may display it. XSPF::Track objects MAY contain exactly one. def creator; begin; @track.elements['creator'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # A human-readable comment on the track. This is character data, not HTML, and it may not contain markup. XSPF::Track objects MAY contain exactly one. def annotation; begin; @track.elements['annotation'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # URL of a place where this resource can be bought or more info can be found. def info; begin; @track.elements['info'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # URL of an image to display for the duration of the track. XSPF::Track objects MAY contain exactly one. def image; begin; @track.elements['image'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # Human-readable name of the collection from which the resource which defines the duration of track rendering comes. For a song originally published as a part of a CD or LP, this would be the title of the original release. This value is primarily for fuzzy lookups, though a user-agent may display it. XSPF::Track objects MAY contain exactly one. def album; begin; @track.elements['album'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # Integer with value greater than zero giving the ordinal position of the media on the XSPF::Track#album. This value is primarily for fuzzy lookups, though a user-agent may display it. XSPF::Track objects MAY contain exactly one. It MUST be a valid XML Schema nonNegativeInteger. def tracknum; begin; @track.elements['trackNum'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # The time to render a resource, in milliseconds. It MUST be a valid XML Schema nonNegativeInteger. This value is only a hint -- different XSPF generators will generate slightly different values. A user-agent MUST NOT use this value to determine the rendering duration, since the data will likely be low quality. XSPF::Track objects MAY contain exactly one duration element. def duration; begin; @track.elements['duration'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # The extension element allows non-XSPF XML to be included in XSPF documents without breaking XSPF validation. The purpose is to allow nested XML, which the meta and link elements do not. XSPF::Track objects MAY contain zero or more extension elements, but currently XSPF for Ruby returns only the first one. def extension; begin; @track.elements['extension'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # The link element allows non-XSPF web resources to be included in XSPF documents without breaking XSPF validation. A valid 'link' element has a 'rel' attribute and a 'content' element, obtained with XSPF::Track#link_rel and XSPF::Track#link_content respectively. XSPF::Track objects MAY contain zero or more meta elements, but currently XSPF for Ruby returns only the first one. def link_content; begin; @track.elements['link'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # The link element allows non-XSPF web resources to be included in XSPF documents without breaking XSPF validation. A valid 'link' element has a 'rel' attribute and a 'content' element, obtained with XSPF::Track#link_rel and XSPF::Track#link_content respectively. XSPF::Track objects MAY contain zero or more link elements, but currently XSPF for Ruby returns only the first one. def link_rel; begin; @track.elements['link'].attributes['rel']; rescue NoMethodError; return nil; end; end end class XSPF::Track # The meta element allows non-XSPF metadata to be included in XSPF documents without breaking XSPF validation. A valid 'meta' element has a 'rel' attribute and a 'content' element, obtained with XSPF::Track#meta_rel and XSPF::Track#meta_content respectively. XSPF::Track objects MAY contain zero or more meta elements, but currently XSPF for Ruby returns only the first one. def meta_content; begin; @track.elements['meta'].text; rescue NoMethodError; return nil; end; end end class XSPF::Track # The meta element allows non-XSPF metadata to be included in XSPF documents without breaking XSPF validation. A valid 'meta' element has a 'rel' attribute and a 'content' element, obtained with XSPF::Track#meta_rel and XSPF::Track#meta_content respectively. XSPF::Track objects MAY contain zero or more meta elements, but currently XSPF for Ruby returns only the first one. def meta_rel; begin; @track.elements['meta'].attributes['rel']; rescue NoMethodError; return nil; end; end end