coverage/lib-xspf_rb.html in xspf-0.3 vs coverage/lib-xspf_rb.html in xspf-0.4
- old
+ new
@@ -552,11 +552,11 @@
}
</style>
</head>
<body>
<h3>C0 code coverage information</h3>
- <p>Generated on Fri Oct 20 17:20:35 CEST 2006 with <a href='http://eigenclass.org/hiki.rb?rcov'>rcov 0.7.0</a>
+ <p>Generated on Mon Oct 30 22:55:21 CET 2006 with <a href='http://eigenclass.org/hiki.rb?rcov'>rcov 0.7.0</a>
</p>
<hr /><pre><span class='marked0'>Code reported as executed by Ruby looks like this...
</span><span class='marked1'>and this: this line is also marked as covered.
</span><span class='inferred0'>Lines considered as run by rcov, but not reported by Ruby, look like this,
</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).
@@ -576,41 +576,41 @@
<tr class='light'>
<td>
<a href='lib-xspf_rb.html'>lib/xspf.rb</a>
</td>
<td class='value'>
- <tt>319</tt>
+ <tt>480</tt>
</td>
<td class='value'>
- <tt>126</tt>
+ <tt>321</tt>
</td>
<td>
<table cellspacing='0' cellpadding='0' align='right'>
<tr>
<td>
- <tt>95.6%</tt> </td>
+ <tt>100.0%</tt> </td>
<td>
<table cellspacing='0' class='percent_graph' cellpadding='0' width='100'>
<tr>
- <td class='covered' width='96' />
- <td class='uncovered' width='4' />
+ <td class='covered' width='100' />
+ <td class='uncovered' width='0' />
</tr>
</table>
</td>
</tr>
</table>
</td>
<td>
<table cellspacing='0' cellpadding='0' align='right'>
<tr>
<td>
- <tt>91.3%</tt> </td>
+ <tt>100.0%</tt> </td>
<td>
<table cellspacing='0' class='percent_graph' cellpadding='0' width='100'>
<tr>
- <td class='covered' width='91' />
- <td class='uncovered' width='9' />
+ <td class='covered' width='100' />
+ <td class='uncovered' width='0' />
</tr>
</table>
</td>
</tr>
</table>
@@ -624,319 +624,480 @@
</span><span class="inferred1"><a name="line5" /> 5 #
</span><span class="inferred0"><a name="line6" /> 6 # This library may be used only as allowed by either the Ruby license (or, by
</span><span class="inferred1"><a name="line7" /> 7 # association with the Ruby license, the GPL). See the "doc" subdirectory of
</span><span class="inferred0"><a name="line8" /> 8 # the XSPF distribution for the texts of these licenses.
</span><span class="inferred1"><a name="line9" /> 9 # -----------------------------------------------------------------------------
-</span><span class="inferred0"><a name="line10" /> 10 # XSPF for Ruby website : http://www.elpauer.org/xspf
+</span><span class="inferred0"><a name="line10" /> 10 # XSPF for Ruby website : http://xspf.rubyforge.org
</span><span class="inferred1"><a name="line11" /> 11 # =============================================================================
</span><span class="inferred0"><a name="line12" /> 12 #++
</span><span class="inferred1"><a name="line13" /> 13
</span><span class="marked0"><a name="line14" /> 14 require 'rexml/document'
</span><span class="marked1"><a name="line15" /> 15 require 'xml/xslt'
</span><span class="inferred0"><a name="line16" /> 16
-</span><span class="inferred1"><a name="line17" /> 17 # :main: XSPF
-</span><span class="inferred0"><a name="line18" /> 18
-</span><span class="marked1"><a name="line19" /> 19 module MetaGen #:nodoc:
-</span><span class="inferred0"><a name="line20" /> 20
-</span><span class="inferred1"><a name="line21" /> 21 # define the method
-</span><span class="marked0"><a name="line22" /> 22 def self.add_method(klass, meth_name, body, meth_rdoc)
-</span><span class="marked1"><a name="line23" /> 23 code = "# #{meth_rdoc}\n def #{meth_name.downcase}; begin; #{body}; rescue NoMethodError; return nil; end; end"
-</span><span class="inferred0"><a name="line24" /> 24
-</span><span class="marked1"><a name="line25" /> 25 klass.module_eval(code)
-</span><span class="inferred0"><a name="line26" /> 26
-</span><span class="inferred1"><a name="line27" /> 27 # hook to write klass + name attrib to a file
-</span><span class="marked0"><a name="line28" /> 28 if $META_RDOC
-</span><span class="uncovered1"><a name="line29" /> 29 open($META_RDOC, 'a+') do |f|
-</span><span class="uncovered0"><a name="line30" /> 30 f.puts("class #{klass}\n #{code}\n end")
-</span><span class="uncovered1"><a name="line31" /> 31 end
-</span><span class="uncovered0"><a name="line32" /> 32 end
-</span><span class="uncovered1"><a name="line33" /> 33
-</span><span class="uncovered0"><a name="line34" /> 34 end
-</span><span class="inferred1"><a name="line35" /> 35
-</span><span class="inferred0"><a name="line36" /> 36 # output in different formats
-</span><span class="marked1"><a name="line37" /> 37 def self.add_output_format(klass, format, xspf, meth_rdoc)
-</span><span class="marked0"><a name="line38" /> 38 xslt_path = "'#{File.join( File.dirname(__FILE__), %Q{xspf2#{format}.xsl} )}'"
-</span><span class="marked1"><a name="line39" /> 39 code = "# #{meth_rdoc}\n def to_#{format}; xslt = XML::XSLT.new; xslt.xml = xspf; xslt.xsl = REXML::Document.new( File.new( #{xslt_path} ) ); xslt.serve; end"
-</span><span class="inferred0"><a name="line40" /> 40
-</span><span class="marked1"><a name="line41" /> 41 klass.module_eval(code)
-</span><span class="inferred0"><a name="line42" /> 42
-</span><span class="marked1"><a name="line43" /> 43 if $META_RDOC
-</span><span class="uncovered0"><a name="line44" /> 44 open($META_RDOC, 'a+') do |f|
-</span><span class="uncovered1"><a name="line45" /> 45 f.puts("class #{klass}\n #{code}\n end")
-</span><span class="uncovered0"><a name="line46" /> 46 end
-</span><span class="uncovered1"><a name="line47" /> 47 end
-</span><span class="uncovered0"><a name="line48" /> 48
-</span><span class="uncovered1"><a name="line49" /> 49 end
-</span><span class="uncovered0"><a name="line50" /> 50
-</span><span class="uncovered1"><a name="line51" /> 51 end
-</span><span class="inferred0"><a name="line52" /> 52
-</span><span class="inferred1"><a name="line53" /> 53 # XML Shareable Playlist Format (XSPF[http://www.xspf.org]) parser for Ruby
-</span><span class="inferred0"><a name="line54" /> 54 #
-</span><span class="inferred1"><a name="line55" /> 55 # When parsing, if a XSPF attribute or element is not set, the corresponding method will return _nil_.
-</span><span class="inferred0"><a name="line56" /> 56 #
-</span><span class="inferred1"><a name="line57" /> 57 # === Examples
-</span><span class="inferred0"><a name="line58" /> 58 # ==== Parse from file
-</span><span class="inferred1"><a name="line59" /> 59 # require 'xspf'
-</span><span class="inferred0"><a name="line60" /> 60 #
-</span><span class="inferred1"><a name="line61" /> 61 # f = File.new("playlist.xspf")
-</span><span class="inferred0"><a name="line62" /> 62 # x = XSPF.new(f)
-</span><span class="inferred1"><a name="line63" /> 63 # pl = XSPF::Playlist.new(x)
-</span><span class="inferred0"><a name="line64" /> 64 # tl = XSPF::Tracklist.new(pl)
-</span><span class="inferred1"><a name="line65" /> 65 #
-</span><span class="inferred0"><a name="line66" /> 66 # puts "XML version: #{x.version}"
-</span><span class="inferred1"><a name="line67" /> 67 # puts "XML encoding: #{ x.encoding}"
-</span><span class="inferred0"><a name="line68" /> 68 # puts "XSPF version: #{pl.version}"
-</span><span class="inferred1"><a name="line69" /> 69 # puts "Namespace: #{pl.xmlns}"
-</span><span class="inferred0"><a name="line70" /> 70 # puts "Playlist title: #{pl.title}"
-</span><span class="inferred1"><a name="line71" /> 71 # puts "Playlist creator: #{pl.creator}"
-</span><span class="inferred0"><a name="line72" /> 72 # puts "Playlist annotation: #{pl.annotation}"
-</span><span class="inferred1"><a name="line73" /> 73 # puts "Playlist info: #{pl.info}"
-</span><span class="inferred0"><a name="line74" /> 74 # puts "Playlist identifier: #{pl.identifier}"
-</span><span class="inferred1"><a name="line75" /> 75 # puts "Playlist attribution: #{pl.attribution}"
-</span><span class="inferred0"><a name="line76" /> 76 # puts "Tracklist: #{pl.tracklist}"
-</span><span class="inferred1"><a name="line77" /> 77 # tl.tracks.each do |t|
-</span><span class="inferred0"><a name="line78" /> 78 # puts "Track identifier: #{t.identifier}"
-</span><span class="inferred1"><a name="line79" /> 79 # puts "Track title: #{t.title}"
-</span><span class="inferred0"><a name="line80" /> 80 # puts "Track creator: #{t.creator}"
-</span><span class="inferred1"><a name="line81" /> 81 # puts "Track duration: #{t.duration}"
-</span><span class="inferred0"><a name="line82" /> 82 # puts "Track metainformation: link=#{t.meta_rel} content=#{t.meta_content}"
-</span><span class="inferred1"><a name="line83" /> 83 # end
-</span><span class="inferred0"><a name="line84" /> 84 #
-</span><span class="inferred1"><a name="line85" /> 85 # # Convert the XSPF document to SMIL
-</span><span class="inferred0"><a name="line86" /> 86 # x.to_smil
-</span><span class="inferred1"><a name="line87" /> 87 #
-</span><span class="inferred0"><a name="line88" /> 88 # # Convert the XSPF document to HTML
-</span><span class="inferred1"><a name="line89" /> 89 # x.to_html
-</span><span class="inferred0"><a name="line90" /> 90 #
-</span><span class="inferred1"><a name="line91" /> 91 # # Convert the XSPF document in a M3U playlist
-</span><span class="inferred0"><a name="line92" /> 92 # x.to_m3u
-</span><span class="inferred1"><a name="line93" /> 93 #
-</span><span class="inferred0"><a name="line94" /> 94 # ==== Parse from string
-</span><span class="inferred1"><a name="line95" /> 95 # playlist_document = <<-END_OF_PLAYLIST
-</span><span class="inferred0"><a name="line96" /> 96 # <?xml version="1.0" encoding="UTF-8"?>
-</span><span class="inferred1"><a name="line97" /> 97 # <playlist version="0" xmlns="http://xspf.org/ns/0/">
-</span><span class="inferred0"><a name="line98" /> 98 # <title>XSPlF it up!</title>
-</span><span class="inferred1"><a name="line99" /> 99 # <creator>Mayhem &amp; Chaos Coordinator</creator>
-</span><span class="inferred0"><a name="line100" />100 # <annotation>Just a few songs to enjoy while you XSPlF it up!</annotation>
-</span><span class="inferred1"><a name="line101" />101 # <info>http://mayhem-chaos.net/xspf/xspf_it_up.html</info>
-</span><span class="inferred0"><a name="line102" />102 # <identifier>http://mayhem-chaos.net/xspf/xspf_it_up/1.0</identifier>
-</span><span class="inferred1"><a name="line103" />103 # <attribution>
-</span><span class="inferred0"><a name="line104" />104 # <location>ihttp://mayhem-chaos.net/xspf/xspf_it_up.html</location>
-</span><span class="inferred1"><a name="line105" />105 # </attribution>
-</span><span class="inferred0"><a name="line106" />106 # <trackList>
-</span><span class="inferred1"><a name="line107" />107 # <track>
-</span><span class="inferred0"><a name="line108" />108 # <identifier>http://musicbrainz.org/track/bdab6db0-2fd6-4166-a5fa-fbf2ff213793</identifier>
-</span><span class="inferred1"><a name="line109" />109 # <title>I Wanna Get High</title>
-</span><span class="inferred0"><a name="line110" />110 # <creator>Cypress Hill</creator>
-</span><span class="inferred1"><a name="line111" />111 # <duration>174613</duration>
-</span><span class="inferred0"><a name="line112" />112 # <meta rel="http://musicbrainz.org/track">http://musicbrainz.org/mm-2.1/track/bdab6db0-2fd6-4166-a5fa-fbf2ff213793</meta>
-</span><span class="inferred1"><a name="line113" />113 # </track>
-</span><span class="inferred0"><a name="line114" />114 # <track>
-</span><span class="inferred1"><a name="line115" />115 # <identifier>bdc846e7-6c26-4193-82a6-8d1b5a4d3429</identifier>
-</span><span class="inferred0"><a name="line116" />116 # <title>Smoke Two Joints</title>
-</span><span class="inferred1"><a name="line117" />117 # <creator>Sublime</creator>
-</span><span class="inferred0"><a name="line118" />118 # <duration>175466</duration>
-</span><span class="inferred1"><a name="line119" />119 # <meta rel="http://musicbrainz.org/track">http://musicbrainz.org/mm-2.1/track/bdc846e7-6c26-4193-82a6-8d1b5a4d3429</meta>
-</span><span class="inferred0"><a name="line120" />120 # </track>
-</span><span class="inferred1"><a name="line121" />121 # <track>
-</span><span class="inferred0"><a name="line122" />122 # <identifier>http://musicbrainz.org/track/7d9776f7-d428-40dc-a425-3c6e3dce4d58</identifier>
-</span><span class="inferred1"><a name="line123" />123 # <title>Hash Pipe</title>
-</span><span class="inferred0"><a name="line124" />124 # <creator>Weezer</creator>
-</span><span class="inferred1"><a name="line125" />125 # <duration>186533</duration>
-</span><span class="inferred0"><a name="line126" />126 # <meta rel="http://musicbrainz.org/track">http://musicbrainz.org/mm-2.1/track/7d9776f7-d428-40dc-a425-3c6e3dce4d58</meta>
-</span><span class="inferred1"><a name="line127" />127 # </track>
-</span><span class="inferred0"><a name="line128" />128 # </trackList>
-</span><span class="inferred1"><a name="line129" />129 # </playlist>
-</span><span class="inferred0"><a name="line130" />130 # END_OF_PLAYLIST
-</span><span class="inferred1"><a name="line131" />131 #
-</span><span class="inferred0"><a name="line132" />132 # x = XSPF.new(playlist_document)
-</span><span class="inferred1"><a name="line133" />133 # pl = XSPF::Playlist.new(x)
-</span><span class="inferred0"><a name="line134" />134 # tl = XSPF::Tracklist.new(pl)
-</span><span class="inferred1"><a name="line135" />135 #
-</span><span class="inferred0"><a name="line136" />136 # puts "XML version: #{x.version}"
-</span><span class="inferred1"><a name="line137" />137 # puts "XML encoding: #{ x.encoding}"
-</span><span class="inferred0"><a name="line138" />138 # puts "XSPF version: #{pl.version}"
-</span><span class="inferred1"><a name="line139" />139 # puts "Namespace: #{pl.xmlns}"
-</span><span class="inferred0"><a name="line140" />140 # puts "Playlist title: #{pl.title}"
-</span><span class="inferred1"><a name="line141" />141 # puts "Playlist creator: #{pl.creator}"
-</span><span class="inferred0"><a name="line142" />142 # puts "Playlist annotation: #{pl.annotation}"
-</span><span class="inferred1"><a name="line143" />143 # puts "Playlist info: #{pl.info}"
-</span><span class="inferred0"><a name="line144" />144 # puts "Playlist identifier: #{pl.identifier}"
-</span><span class="inferred1"><a name="line145" />145 # puts "Playlist attribution: #{pl.attribution}"
-</span><span class="inferred0"><a name="line146" />146 # puts "Tracklist: #{pl.tracklist}"
-</span><span class="inferred1"><a name="line147" />147 # tl.tracks.each do |t|
-</span><span class="inferred0"><a name="line148" />148 # puts "Track identifier: #{t.identifier}"
-</span><span class="inferred1"><a name="line149" />149 # puts "Track title: #{t.title}"
-</span><span class="inferred0"><a name="line150" />150 # puts "Track creator: #{t.creator}"
-</span><span class="inferred1"><a name="line151" />151 # puts "Track duration: #{t.duration}"
-</span><span class="inferred0"><a name="line152" />152 # puts "Track metainformation: link=#{t.meta_rel} content=#{t.meta_content}"
-</span><span class="inferred1"><a name="line153" />153 # end
-</span><span class="inferred0"><a name="line154" />154 #
-</span><span class="inferred1"><a name="line155" />155 # # Convert the XSPF document to SMIL
-</span><span class="inferred0"><a name="line156" />156 # x.to_smil
-</span><span class="inferred1"><a name="line157" />157 #
-</span><span class="inferred0"><a name="line158" />158 # # Convert the XSPF document to HTML
-</span><span class="inferred1"><a name="line159" />159 # x.to_html
-</span><span class="inferred0"><a name="line160" />160 #
-</span><span class="inferred1"><a name="line161" />161 # # Convert the XSPF document in a M3U playlist
-</span><span class="inferred0"><a name="line162" />162 # x.to_m3u
-</span><span class="inferred1"><a name="line163" />163 #
-</span><span class="inferred0"><a name="line164" />164
-</span><span class="marked1"><a name="line165" />165 class XSPF
+</span><span class="inferred1"><a name="line17" /> 17 # :include: USAGE
+</span><span class="inferred0"><a name="line18" /> 18 # :main: USAGE
+</span><span class="inferred1"><a name="line19" /> 19
+</span><span class="marked0"><a name="line20" /> 20 module MetaGen #:nodoc:
+</span><span class="inferred1"><a name="line21" /> 21
+</span><span class="inferred0"><a name="line22" /> 22 # define the method
+</span><span class="marked1"><a name="line23" /> 23 def self.add_method(klass, meth_name, body, meth_rdoc)
+</span><span class="marked0"><a name="line24" /> 24 code = <<-CODE
+</span><span class="inferred1"><a name="line25" /> 25 # #{meth_rdoc}
+</span><span class="inferred0"><a name="line26" /> 26 def #{meth_name.downcase}
+</span><span class="inferred1"><a name="line27" /> 27 @#{meth_name}
+</span><span class="inferred0"><a name="line28" /> 28 end
+</span><span class="inferred1"><a name="line29" /> 29
+</span><span class="inferred0"><a name="line30" /> 30 def #{meth_name.downcase}=(value)
+</span><span class="inferred1"><a name="line31" /> 31 @#{meth_name.downcase} = value
+</span><span class="inferred0"><a name="line32" /> 32 end
+</span><span class="inferred1"><a name="line33" /> 33
+</span><span class="inferred0"><a name="line34" /> 34 private
+</span><span class="inferred1"><a name="line35" /> 35 def parse_#{meth_name.downcase}
+</span><span class="inferred0"><a name="line36" /> 36 begin
+</span><span class="inferred1"><a name="line37" /> 37 #{body}
+</span><span class="inferred0"><a name="line38" /> 38 rescue NoMethodError
+</span><span class="inferred1"><a name="line39" /> 39 return nil
+</span><span class="inferred0"><a name="line40" /> 40 end
+</span><span class="inferred1"><a name="line41" /> 41 end
+</span><span class="inferred0"><a name="line42" /> 42 CODE
+</span><span class="inferred1"><a name="line43" /> 43
+</span><span class="marked0"><a name="line44" /> 44 klass.module_eval(code)
+</span><span class="inferred1"><a name="line45" /> 45
+</span><span class="inferred0"><a name="line46" /> 46 # hook to write klass + name attrib to a file
+</span><span class="marked1"><a name="line47" /> 47 if $META_RDOC
+</span><span class="marked0"><a name="line48" /> 48 open($META_RDOC, 'a+') do |f|
+</span><span class="marked1"><a name="line49" /> 49 f.puts("class #{klass}\n #{code}\n end")
+</span><span class="inferred0"><a name="line50" /> 50 end
+</span><span class="inferred1"><a name="line51" /> 51 end
+</span><span class="inferred0"><a name="line52" /> 52
+</span><span class="inferred1"><a name="line53" /> 53 end
+</span><span class="inferred0"><a name="line54" /> 54
+</span><span class="inferred1"><a name="line55" /> 55 # output in different formats
+</span><span class="inferred0"><a name="line56" /> 56 # FIXME Only works in parse mode, not in generation mode.
+</span><span class="marked1"><a name="line57" /> 57 def self.add_output_format(klass, format, meth_rdoc)
+</span><span class="marked0"><a name="line58" /> 58 xslt_path = "'#{File.join( File.dirname(__FILE__), %Q{xspf2#{format}.xsl} )}'"
+</span><span class="marked1"><a name="line59" /> 59 code = <<-CODE
+</span><span class="inferred0"><a name="line60" /> 60 # #{meth_rdoc}
+</span><span class="inferred1"><a name="line61" /> 61 def to_#{format}
+</span><span class="inferred0"><a name="line62" /> 62 xslt = XML::XSLT.new
+</span><span class="inferred1"><a name="line63" /> 63 xslt.xml = self.to_xml
+</span><span class="inferred0"><a name="line64" /> 64 xslt.xsl = REXML::Document.new( File.new( #{xslt_path} ) )
+</span><span class="inferred1"><a name="line65" /> 65 xslt.serve
+</span><span class="inferred0"><a name="line66" /> 66 end
+</span><span class="inferred1"><a name="line67" /> 67 CODE
+</span><span class="inferred0"><a name="line68" /> 68
+</span><span class="marked1"><a name="line69" /> 69 klass.module_eval(code)
+</span><span class="inferred0"><a name="line70" /> 70
+</span><span class="marked1"><a name="line71" /> 71 if $META_RDOC
+</span><span class="marked0"><a name="line72" /> 72 open($META_RDOC, 'a+') do |f|
+</span><span class="marked1"><a name="line73" /> 73 f.puts("class #{klass}\n #{code}\n end")
+</span><span class="inferred0"><a name="line74" /> 74 end
+</span><span class="inferred1"><a name="line75" /> 75 end
+</span><span class="inferred0"><a name="line76" /> 76
+</span><span class="inferred1"><a name="line77" /> 77 end
+</span><span class="inferred0"><a name="line78" /> 78
+</span><span class="inferred1"><a name="line79" /> 79 end
+</span><span class="inferred0"><a name="line80" /> 80
+</span><span class="marked1"><a name="line81" /> 81 class XSPF
+</span><span class="inferred0"><a name="line82" /> 82
+</span><span class="marked1"><a name="line83" /> 83 attr_reader :xspf
+</span><span class="inferred0"><a name="line84" /> 84
+</span><span class="inferred1"><a name="line85" /> 85 #:stopdoc:
+</span><span class="marked0"><a name="line86" /> 86 ATTRIBUTES = %w{ version encoding }
+</span><span class="marked1"><a name="line87" /> 87 VERSION_RDOC = 'Version for the XML document or _nil_ if not defined'
+</span><span class="marked0"><a name="line88" /> 88 ENCODING_RDOC = 'Encoding of the XML document or _nil_ if not defined'
+</span><span class="inferred1"><a name="line89" /> 89
+</span><span class="marked0"><a name="line90" /> 90 OUTPUT_FORMATS = %w{ m3u html smil soundblox }
+</span><span class="marked1"><a name="line91" /> 91 M3U_RDOC = 'Creates a .m3u playlist from the XSPF document. This method makes use of the official XSPF to M3U XSLT transformation by Lucas Gonze.'
+</span><span class="marked0"><a name="line92" /> 92 HTML_RDOC = 'Outputs the playlist as an HTML page. This method makes use of the official XSPF to HTML XSLT transformation by Lucas Gonze.'
+</span><span class="marked1"><a name="line93" /> 93 SMIL_RDOC = 'Creates a .smil playlist from the XSPF document. This method makes use of the official XSPF to SMIL XSLT transformation by Lucas Gonze.'
+</span><span class="marked0"><a name="line94" /> 94 SOUNDBLOX_RDOC = 'Creates a SoundBlox playlist from the XSPF document. This method makes use of the official XSPF to SoundBlox XSLT tranformation by Lucas Gonze.'
+</span><span class="inferred1"><a name="line95" /> 95
+</span><span class="marked0"><a name="line96" /> 96 ATTRIBUTES.each do |attrib|
+</span><span class="marked1"><a name="line97" /> 97 MetaGen.add_method(self, attrib, "@xspf.#{attrib}", eval(attrib.upcase + '_RDOC').to_s )
+</span><span class="inferred0"><a name="line98" /> 98 end
+</span><span class="inferred1"><a name="line99" /> 99
+</span><span class="marked0"><a name="line100" />100 OUTPUT_FORMATS.each do |format|
+</span><span class="marked1"><a name="line101" />101 MetaGen.add_output_format(self, format, eval(format.upcase + '_RDOC').to_s )
+</span><span class="inferred0"><a name="line102" />102 end
+</span><span class="inferred1"><a name="line103" />103
+</span><span class="inferred0"><a name="line104" />104 #:startdoc:
+</span><span class="inferred1"><a name="line105" />105
+</span><span class="inferred0"><a name="line106" />106 # Creates a XSPF object from a file or string (parse mode) or from a hash or nil (generation mode).
+</span><span class="inferred1"><a name="line107" />107 #
+</span><span class="inferred0"><a name="line108" />108 # Possible keys in the hash: :version, :encoding
+</span><span class="marked1"><a name="line109" />109 def initialize(source = nil)
+</span><span class="marked0"><a name="line110" />110 if ( source.nil? || source.instance_of?(Hash) ) then
+</span><span class="marked1"><a name="line111" />111 @version = if source.nil? || !source.has_key?(:version)
+</span><span class="marked0"><a name="line112" />112 '1.0'
+</span><span class="inferred1"><a name="line113" />113 else
+</span><span class="marked0"><a name="line114" />114 source[:version]
+</span><span class="inferred1"><a name="line115" />115 end
+</span><span class="marked0"><a name="line116" />116 @encoding = if source.nil? || !source.has_key?(:encoding)
+</span><span class="marked1"><a name="line117" />117 'UTF-8'
+</span><span class="inferred0"><a name="line118" />118 else
+</span><span class="marked1"><a name="line119" />119 source[:encoding]
+</span><span class="inferred0"><a name="line120" />120 end
+</span><span class="marked1"><a name="line121" />121 @playlist = nil
+</span><span class="marked0"><a name="line122" />122 @playlist = if !source.nil? && source.has_key?(:playlist) then
+</span><span class="marked1"><a name="line123" />123 if source[:playlist].instance_of?(XSPF::Playlist)
+</span><span class="marked0"><a name="line124" />124 source[:playlist]
+</span><span class="inferred1"><a name="line125" />125 else
+</span><span class="marked0"><a name="line126" />126 raise(TypeError, 'You must pass a file/string (parsing mode) or a hash/nothing (generator mode) as argument to XSPF#new')
+</span><span class="inferred1"><a name="line127" />127 end
+</span><span class="inferred0"><a name="line128" />128 end
+</span><span class="inferred1"><a name="line129" />129
+</span><span class="marked0"><a name="line130" />130 elsif ( source.instance_of?(File) || source.instance_of?(String) ) then
+</span><span class="marked1"><a name="line131" />131 @xspf = REXML::Document.new(source)
+</span><span class="marked0"><a name="line132" />132 ATTRIBUTES.each do |attrib|
+</span><span class="marked1"><a name="line133" />133 eval('@' + attrib + '= parse_' + attrib)
+</span><span class="inferred0"><a name="line134" />134 end
+</span><span class="inferred1"><a name="line135" />135
+</span><span class="marked0"><a name="line136" />136 @playlist = XSPF::Playlist.new(self)
+</span><span class="inferred1"><a name="line137" />137
+</span><span class="inferred0"><a name="line138" />138 else
+</span><span class="marked1"><a name="line139" />139 raise(TypeError, 'You must pass a file/string (parsing mode) or a hash/nothing (generator mode) as argument to XSPF#new')
+</span><span class="inferred0"><a name="line140" />140 end
+</span><span class="marked1"><a name="line141" />141 end
+</span><span class="inferred0"><a name="line142" />142
+</span><span class="inferred1"><a name="line143" />143 # A XSPF::Playlist object
+</span><span class="marked0"><a name="line144" />144 def playlist
+</span><span class="marked1"><a name="line145" />145 @playlist
+</span><span class="marked0"><a name="line146" />146 end
+</span><span class="inferred1"><a name="line147" />147
+</span><span class="marked0"><a name="line148" />148 def playlist=(value)
+</span><span class="marked1"><a name="line149" />149 raise(TypeError, 'The playlist must be an instance of XSPF::Playlist') unless value.instance_of?(XSPF::Playlist)
+</span><span class="marked0"><a name="line150" />150 @playlist = value
+</span><span class="inferred1"><a name="line151" />151 end
+</span><span class="inferred0"><a name="line152" />152
+</span><span class="inferred1"><a name="line153" />153 # Exports the XSPF object to XML
+</span><span class="marked0"><a name="line154" />154 def to_xml
+</span><span class="marked1"><a name="line155" />155 xml = REXML::Document.new
+</span><span class="marked0"><a name="line156" />156 xml << REXML::XMLDecl.new(@version, @encoding)
+</span><span class="marked1"><a name="line157" />157 xml << REXML::Document.new(@playlist.to_xml) unless @playlist.nil?
+</span><span class="marked0"><a name="line158" />158 xml.to_s
+</span><span class="inferred1"><a name="line159" />159 end
+</span><span class="inferred0"><a name="line160" />160
+</span><span class="inferred1"><a name="line161" />161 # The <playlist> section of the XSPF document (outputs XML code). This method is only used while parsing.
+</span><span class="marked0"><a name="line162" />162 protected
+</span><span class="marked1"><a name="line163" />163 def playlist_xml
+</span><span class="marked0"><a name="line164" />164 @xspf.root
+</span><span class="marked1"><a name="line165" />165 end
</span><span class="inferred0"><a name="line166" />166
-</span><span class="marked1"><a name="line167" />167 attr_reader :xspf
+</span><span class="inferred1"><a name="line167" />167 end
</span><span class="inferred0"><a name="line168" />168
-</span><span class="inferred1"><a name="line169" />169 #:stopdoc:
-</span><span class="marked0"><a name="line170" />170 ATTRIBUTES = %w{ version encoding }
-</span><span class="marked1"><a name="line171" />171 VERSION_RDOC = "Version for the XML document or _nil_ if not defined"
-</span><span class="marked0"><a name="line172" />172 ENCODING_RDOC = "Encoding of the XML document or _nil_ if not defined"
-</span><span class="inferred1"><a name="line173" />173
-</span><span class="marked0"><a name="line174" />174 OUTPUT_FORMATS = %w{ m3u html smil soundblox }
-</span><span class="marked1"><a name="line175" />175 M3U_RDOC = "Creates a .m3u playlist from the XSPF document. This method makes use of the official XSPF to M3U XSLT transformation by Lucas Gonze."
-</span><span class="marked0"><a name="line176" />176 HTML_RDOC = "Outputs the playlist as an HTML page. This method makes use of the official XSPF to HTML XSLT transformation by Lucas Gonze."
-</span><span class="marked1"><a name="line177" />177 SMIL_RDOC = "Creates a .smil playlist from the XSPF document. This method makes use of the official XSPF to SMIL XSLT transformation by Lucas Gonze."
-</span><span class="marked0"><a name="line178" />178 SOUNDBLOX_RDOC = "Creates a SoundBlox playlist from the XSPF document. This method makes use of the official XSPF to SoundBlox XSLT tranformation by Lucas Gonze."
-</span><span class="inferred1"><a name="line179" />179
-</span><span class="marked0"><a name="line180" />180 ATTRIBUTES.each do |attrib|
-</span><span class="marked1"><a name="line181" />181 MetaGen.add_method(self, attrib, "@xspf.#{attrib}", eval(attrib.upcase + '_RDOC').to_s )
-</span><span class="inferred0"><a name="line182" />182 end
-</span><span class="inferred1"><a name="line183" />183
-</span><span class="marked0"><a name="line184" />184 OUTPUT_FORMATS.each do |format|
-</span><span class="marked1"><a name="line185" />185 MetaGen.add_output_format(self, format, @xspf, eval(format.upcase + '_RDOC').to_s )
-</span><span class="inferred0"><a name="line186" />186 end
-</span><span class="inferred1"><a name="line187" />187
-</span><span class="inferred0"><a name="line188" />188 #:startdoc:
-</span><span class="inferred1"><a name="line189" />189
-</span><span class="inferred0"><a name="line190" />190 # Creates a XSPF object from a file or string
-</span><span class="marked1"><a name="line191" />191 def initialize(source = nil)
-</span><span class="marked0"><a name="line192" />192 @xspf = REXML::Document.new(source)
-</span><span class="marked1"><a name="line193" />193 end
-</span><span class="inferred0"><a name="line194" />194
-</span><span class="inferred1"><a name="line195" />195 # The <playlist> section of the XSPF document
-</span><span class="marked0"><a name="line196" />196 def playlist
-</span><span class="marked1"><a name="line197" />197 @xspf.root
-</span><span class="marked0"><a name="line198" />198 end
-</span><span class="inferred1"><a name="line199" />199
-</span><span class="inferred0"><a name="line200" />200 end
-</span><span class="inferred1"><a name="line201" />201
-</span><span class="marked0"><a name="line202" />202 class XSPF::Playlist < XSPF
-</span><span class="inferred1"><a name="line203" />203
-</span><span class="marked0"><a name="line204" />204 attr_reader :playlist
+</span><span class="marked1"><a name="line169" />169 class XSPF::Playlist < XSPF
+</span><span class="inferred0"><a name="line170" />170
+</span><span class="marked1"><a name="line171" />171 attr_reader :playlist
+</span><span class="inferred0"><a name="line172" />172
+</span><span class="inferred1"><a name="line173" />173 #:stopdoc:
+</span><span class="marked0"><a name="line174" />174 ATTRIBUTES = %w{ xmlns version }
+</span><span class="marked1"><a name="line175" />175 ELEMENTS = %w{ title creator annotation info location identifier image date license attribution extension }
+</span><span class="marked0"><a name="line176" />176 ATTRIBUTE_AND_ELEMENT = %w{ link meta }
+</span><span class="marked1"><a name="line177" />177 ATTRIBUTION_CHILD_ELEMENTS = %w{ location identifier }
+</span><span class="marked0"><a name="line178" />178 EXTENSION_CHILD_ELEMENTS = %w{ application content }
+</span><span class="inferred1"><a name="line179" />179
+</span><span class="marked0"><a name="line180" />180 XMLNS_RDOC = 'The XML namespace. It must be http://xspf.org/ns/0/ for a valid XSPF document.'
+</span><span class="marked1"><a name="line181" />181 XMLNS_DEFAULT = 'http://xspf.org/ns/0/'
+</span><span class="marked0"><a name="line182" />182 VERSION_RDOC = 'The XSPF version. It may be 0 or 1, although 1 is strongly advised.'
+</span><span class="marked1"><a name="line183" />183 VERSION_DEFAULT = '1'
+</span><span class="marked0"><a name="line184" />184 TITLE_RDOC = 'A human-readable title for the playlist. xspf:playlist elements MAY contain exactly one.'
+</span><span class="marked1"><a name="line185" />185 CREATOR_RDOC = 'Human-readable name of the entity (author, authors, group, company, etc) that authored the playlist. XSPF::Playlist objects MAY contain exactly one.'
+</span><span class="marked0"><a name="line186" />186 ANNOTATION_RDOC = '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.'
+</span><span class="marked1"><a name="line187" />187 INFO_RDOC = '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.'
+</span><span class="marked0"><a name="line188" />188 LOCATION_RDOC = 'Source URL for this playlist. XSPF::Playlist objects MAY contain exactly one.'
+</span><span class="marked1"><a name="line189" />189 IDENTIFIER_RDOC = '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.'
+</span><span class="marked0"><a name="line190" />190 IMAGE_RDOC = 'URL of an image to display if XSPF::Playlist#image return nil. XSPF::Playlist objects MAY contain exactly one.'
+</span><span class="marked1"><a name="line191" />191 DATE_RDOC = 'Creation date (not last-modified date) of the playlist, formatted as a XML schema dateTime. XSPF::Playlist objects MAY contain exactly one.'
+</span><span class="marked0"><a name="line192" />192 LICENSE_RDOC = 'URL of a resource that describes the license under which this playlist was released. XSPF::Playlist objects MAY contain zero or one license element.'
+</span><span class="marked1"><a name="line193" />193 ATTRIBUTION_RDOC = '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.'
+</span><span class="marked0"><a name="line194" />194 EXTENSION_RDOC = '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.'
+</span><span class="marked1"><a name="line195" />195 LINK_REL_RDOC = '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.'
+</span><span class="marked0"><a name="line196" />196 LINK_CONTENT_RDOC = '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.'
+</span><span class="marked1"><a name="line197" />197 META_REL_RDOC = '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.'
+</span><span class="marked0"><a name="line198" />198 META_CONTENT_RDOC = '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.'
+</span><span class="inferred1"><a name="line199" />199
+</span><span class="inferred0"><a name="line200" />200 # FIXME Currently we only return the first "link"
+</span><span class="inferred1"><a name="line201" />201 # FIXME Currently we only return the first "meta"
+</span><span class="inferred0"><a name="line202" />202 # FIXME Currently we only return the first "extension"
+</span><span class="inferred1"><a name="line203" />203 # TODO Parse "attribution"
+</span><span class="inferred0"><a name="line204" />204 # TODO Parse "extension"
</span><span class="inferred1"><a name="line205" />205
-</span><span class="inferred0"><a name="line206" />206 #:stopdoc:
-</span><span class="marked1"><a name="line207" />207 ATTRIBUTES = %w{ xmlns version }
-</span><span class="marked0"><a name="line208" />208 ELEMENTS = %w{ title creator annotation info location identifier image date license attribution extension }
-</span><span class="marked1"><a name="line209" />209 ATTRIBUTE_AND_ELEMENT = %w{ link meta }
-</span><span class="marked0"><a name="line210" />210 attribution_subelements = %w{ location identifier }
-</span><span class="marked1"><a name="line211" />211 extension_subelements = %w{ application content }
-</span><span class="marked0"><a name="line212" />212 XMLNS_RDOC = "The XML namespace. It must be http://xspf.org/ns/0/ for a valid XSPF document."
-</span><span class="marked1"><a name="line213" />213 VERSION_RDOC = "The XSPF version. It may be 0 or 1, although 1 is strongly advised."
-</span><span class="marked0"><a name="line214" />214 TITLE_RDOC = "A human-readable title for the playlist. xspf:playlist elements MAY contain exactly one."
-</span><span class="marked1"><a name="line215" />215 CREATOR_RDOC = "Human-readable name of the entity (author, authors, group, company, etc) that authored the playlist. XSPF::Playlist objects MAY contain exactly one."
-</span><span class="marked0"><a name="line216" />216 ANNOTATION_RDOC = "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."
-</span><span class="marked1"><a name="line217" />217 INFO_RDOC = "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."
-</span><span class="marked0"><a name="line218" />218 LOCATION_RDOC = "Source URL for this playlist. XSPF::Playlist objects MAY contain exactly one."
-</span><span class="marked1"><a name="line219" />219 IDENTIFIER_RDOC = "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."
-</span><span class="marked0"><a name="line220" />220 IMAGE_RDOC = "URL of an image to display if XSPF::Playlist#image return nil. XSPF::Playlist objects MAY contain exactly one."
-</span><span class="marked1"><a name="line221" />221 DATE_RDOC = "Creation date (not last-modified date) of the playlist, formatted as a XML schema dateTime. XSPF::Playlist objects MAY contain exactly one."
-</span><span class="marked0"><a name="line222" />222 LICENSE_RDOC = "URL of a resource that describes the license under which this playlist was released. XSPF::Playlist objects MAY contain zero or one license element."
-</span><span class="marked1"><a name="line223" />223 ATTRIBUTION_RDOC = "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."
-</span><span class="marked0"><a name="line224" />224 EXTENSION_RDOC = "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."
-</span><span class="marked1"><a name="line225" />225 LINK_REL_RDOC = "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."
-</span><span class="marked0"><a name="line226" />226 LINK_CONTENT_RDOC = "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."
-</span><span class="marked1"><a name="line227" />227 META_REL_RDOC = "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."
-</span><span class="marked0"><a name="line228" />228 META_CONTENT_RDOC = "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."
-</span><span class="inferred1"><a name="line229" />229
-</span><span class="inferred0"><a name="line230" />230 # FIXME Currently we only return the first "link"
-</span><span class="inferred1"><a name="line231" />231 # FIXME Currently we only return the first "meta"
-</span><span class="inferred0"><a name="line232" />232 # FIXME Currently we only return the first "extension"
-</span><span class="inferred1"><a name="line233" />233 # TODO Parse "attribution"
-</span><span class="inferred0"><a name="line234" />234 # TODO Parse "extension"
-</span><span class="inferred1"><a name="line235" />235
-</span><span class="inferred0"><a name="line236" />236 # Returns the value of the attribute or nil if the attribute is not present
-</span><span class="marked1"><a name="line237" />237 ATTRIBUTES.each do |attrib|
-</span><span class="marked0"><a name="line238" />238 MetaGen.add_method( self, attrib, "@playlist.root.attributes['#{attrib}']", eval(attrib.upcase + '_RDOC').to_s )
-</span><span class="inferred1"><a name="line239" />239 end
-</span><span class="inferred0"><a name="line240" />240
-</span><span class="marked1"><a name="line241" />241 ELEMENTS.each do |element|
-</span><span class="marked0"><a name="line242" />242 MetaGen.add_method( self, element, "@playlist.elements['#{element}'].text", eval(element.upcase + '_RDOC').to_s )
-</span><span class="inferred1"><a name="line243" />243 end
-</span><span class="inferred0"><a name="line244" />244
-</span><span class="marked1"><a name="line245" />245 ATTRIBUTE_AND_ELEMENT.each do |ae|
-</span><span class="marked0"><a name="line246" />246 MetaGen.add_method( self, "#{ae}_content", "@playlist.elements['#{ae}'].text", eval(ae.upcase + '_CONTENT_RDOC').to_s )
-</span><span class="marked1"><a name="line247" />247 MetaGen.add_method( self, "#{ae}_rel", "@playlist.elements['#{ae}'].attributes['rel']", eval(ae.upcase + '_REL_RDOC').to_s )
-</span><span class="inferred0"><a name="line248" />248 end
+</span><span class="inferred0"><a name="line206" />206 # Returns the value of the attribute or nil if the attribute is not present
+</span><span class="marked1"><a name="line207" />207 ATTRIBUTES.each do |attrib|
+</span><span class="marked0"><a name="line208" />208 MetaGen.add_method( self, attrib, "@playlist.root.attributes['#{attrib}']", eval(attrib.upcase + '_RDOC').to_s )
+</span><span class="inferred1"><a name="line209" />209 end
+</span><span class="inferred0"><a name="line210" />210
+</span><span class="marked1"><a name="line211" />211 ELEMENTS.each do |element|
+</span><span class="marked0"><a name="line212" />212 MetaGen.add_method( self, element, "@playlist.elements['#{element}'].text", eval(element.upcase + '_RDOC').to_s )
+</span><span class="inferred1"><a name="line213" />213 end
+</span><span class="inferred0"><a name="line214" />214
+</span><span class="marked1"><a name="line215" />215 ATTRIBUTE_AND_ELEMENT.each do |ae|
+</span><span class="marked0"><a name="line216" />216 MetaGen.add_method( self, "#{ae}_content", "@playlist.elements['#{ae}'].text", eval(ae.upcase + '_CONTENT_RDOC').to_s )
+</span><span class="marked1"><a name="line217" />217 MetaGen.add_method( self, "#{ae}_rel", "@playlist.elements['#{ae}'].attributes['rel']", eval(ae.upcase + '_REL_RDOC').to_s )
+</span><span class="inferred0"><a name="line218" />218 end
+</span><span class="inferred1"><a name="line219" />219
+</span><span class="inferred0"><a name="line220" />220 #:startdoc:
+</span><span class="inferred1"><a name="line221" />221
+</span><span class="inferred0"><a name="line222" />222 # Creates a XSPF::Playlist from a XSPF document (parse mode) or from a hash of values (generation mode)
+</span><span class="inferred1"><a name="line223" />223 #
+</span><span class="inferred0"><a name="line224" />224 # Possible keys in the hash: :xmlns, :version, :title, :creator, :annotation, :info, :location, :identifier, :image, :date, :license, :attribution, :extension, :link_rel, :link_content, :meta_rel, :meta_content
+</span><span class="marked1"><a name="line225" />225 def initialize(source = nil)
+</span><span class="inferred0"><a name="line226" />226
+</span><span class="marked1"><a name="line227" />227 if ( source.instance_of?(Hash) || source.nil? ) then
+</span><span class="inferred0"><a name="line228" />228
+</span><span class="marked1"><a name="line229" />229 ATTRIBUTES.each do |attrib|
+</span><span class="marked0"><a name="line230" />230 add_instance_variable(source, attrib)
+</span><span class="inferred1"><a name="line231" />231 end
+</span><span class="inferred0"><a name="line232" />232
+</span><span class="marked1"><a name="line233" />233 ELEMENTS.each do |element|
+</span><span class="marked0"><a name="line234" />234 add_instance_variable(source, element)
+</span><span class="inferred1"><a name="line235" />235 end
+</span><span class="inferred0"><a name="line236" />236
+</span><span class="marked1"><a name="line237" />237 ATTRIBUTE_AND_ELEMENT.each do |ae|
+</span><span class="marked0"><a name="line238" />238 add_instance_variable(source, "#{ae}_content" )
+</span><span class="marked1"><a name="line239" />239 add_instance_variable(source, "#{ae}_rel" )
+</span><span class="inferred0"><a name="line240" />240 end
+</span><span class="inferred1"><a name="line241" />241
+</span><span class="marked0"><a name="line242" />242 @tracklist = if ( !source.nil? && source.has_key?(:tracklist) && source[:tracklist].instance_of?(XSPF::Tracklist) )
+</span><span class="marked1"><a name="line243" />243 source[:tracklist]
+</span><span class="inferred0"><a name="line244" />244 else
+</span><span class="marked1"><a name="line245" />245 nil
+</span><span class="inferred0"><a name="line246" />246 end
+</span><span class="inferred1"><a name="line247" />247
+</span><span class="marked0"><a name="line248" />248 elsif source.instance_of?(XSPF) then
</span><span class="inferred1"><a name="line249" />249
-</span><span class="inferred0"><a name="line250" />250 #:startdoc:
-</span><span class="inferred1"><a name="line251" />251
-</span><span class="inferred0"><a name="line252" />252 # Creates a XSPF::Playlist from a XSPF document
-</span><span class="marked1"><a name="line253" />253 def initialize(source)
-</span><span class="marked0"><a name="line254" />254 @playlist = source.playlist
-</span><span class="marked1"><a name="line255" />255 end
-</span><span class="inferred0"><a name="line256" />256
-</span><span class="inferred1"><a name="line257" />257 # The <trackList> section of the XSPF document
-</span><span class="marked0"><a name="line258" />258 def tracklist
-</span><span class="marked1"><a name="line259" />259 @playlist.elements['trackList'] || nil
-</span><span class="marked0"><a name="line260" />260 end
-</span><span class="inferred1"><a name="line261" />261
-</span><span class="inferred0"><a name="line262" />262 end
-</span><span class="inferred1"><a name="line263" />263
-</span><span class="marked0"><a name="line264" />264 class XSPF::Tracklist < XSPF::Playlist
-</span><span class="inferred1"><a name="line265" />265
-</span><span class="marked0"><a name="line266" />266 attr_reader :tracklist
-</span><span class="inferred1"><a name="line267" />267
-</span><span class="inferred0"><a name="line268" />268 # Creates a XSPF::Tracklist from a XSPF::Playlist
-</span><span class="marked1"><a name="line269" />269 def initialize(playlist)
-</span><span class="marked0"><a name="line270" />270 @tracklist = playlist.tracklist
+</span><span class="marked0"><a name="line250" />250 @playlist = source.playlist_xml
+</span><span class="inferred1"><a name="line251" />251
+</span><span class="marked0"><a name="line252" />252 ATTRIBUTES.each do |attrib|
+</span><span class="marked1"><a name="line253" />253 eval('@' + attrib.downcase + '= parse_' + attrib.downcase)
+</span><span class="inferred0"><a name="line254" />254 end
+</span><span class="inferred1"><a name="line255" />255
+</span><span class="marked0"><a name="line256" />256 ELEMENTS.each do |element|
+</span><span class="marked1"><a name="line257" />257 eval('@' + element.downcase + '= parse_' + element.downcase)
+</span><span class="inferred0"><a name="line258" />258 end
+</span><span class="inferred1"><a name="line259" />259
+</span><span class="marked0"><a name="line260" />260 ATTRIBUTE_AND_ELEMENT.each do |ae|
+</span><span class="marked1"><a name="line261" />261 eval('@' + ae.downcase + '_content = parse_' + ae.downcase + '_content')
+</span><span class="marked0"><a name="line262" />262 eval('@' + ae.downcase + '_rel = parse_' + ae.downcase + '_rel')
+</span><span class="inferred1"><a name="line263" />263 end
+</span><span class="inferred0"><a name="line264" />264
+</span><span class="marked1"><a name="line265" />265 @tracklist = XSPF::Tracklist.new(self)
+</span><span class="inferred0"><a name="line266" />266
+</span><span class="inferred1"><a name="line267" />267 else
+</span><span class="marked0"><a name="line268" />268 raise(TypeError, 'You must pass a XSPF object (parsing mode) or a hash (generator mode) as argument to XSPF::Playlist#new')
+</span><span class="inferred1"><a name="line269" />269 end
+</span><span class="inferred0"><a name="line270" />270
</span><span class="marked1"><a name="line271" />271 end
</span><span class="inferred0"><a name="line272" />272
-</span><span class="inferred1"><a name="line273" />273 # An array XSPF::Track objects, one for each track returned by XSPF::Playlist#tracklist
-</span><span class="marked0"><a name="line274" />274 def tracks
-</span><span class="marked1"><a name="line275" />275 @tracklist.elements.collect { |track| XSPF::Track.new(track) }
+</span><span class="inferred1"><a name="line273" />273 # A XSPF::Tracklist object
+</span><span class="marked0"><a name="line274" />274 def tracklist
+</span><span class="marked1"><a name="line275" />275 @tracklist
</span><span class="marked0"><a name="line276" />276 end
</span><span class="inferred1"><a name="line277" />277
-</span><span class="inferred0"><a name="line278" />278 end
-</span><span class="inferred1"><a name="line279" />279
-</span><span class="marked0"><a name="line280" />280 class XSPF::Track
-</span><span class="inferred1"><a name="line281" />281
-</span><span class="marked0"><a name="line282" />282 attr_reader :track
-</span><span class="inferred1"><a name="line283" />283
-</span><span class="inferred0"><a name="line284" />284 #:stopdoc:
-</span><span class="marked1"><a name="line285" />285 ELEMENTS = %w{ location identifier title creator annotation info image album trackNum duration extension }
-</span><span class="marked0"><a name="line286" />286 ATTRIBUTE_AND_ELEMENT = %w{ link meta }
-</span><span class="marked1"><a name="line287" />287 LOCATION_RDOC = "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."
-</span><span class="marked0"><a name="line288" />288 IDENTIFIER_RDOC = "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."
-</span><span class="marked1"><a name="line289" />289 TITLE_RDOC = "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."
-</span><span class="marked0"><a name="line290" />290 CREATOR_RDOC = "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."
-</span><span class="marked1"><a name="line291" />291 ANNOTATION_RDOC = "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."
-</span><span class="marked0"><a name="line292" />292 INFO_RDOC = "URL of a place where this resource can be bought or more info can be found."
-</span><span class="marked1"><a name="line293" />293 IMAGE_RDOC = "URL of an image to display for the duration of the track. XSPF::Track objects MAY contain exactly one."
-</span><span class="marked0"><a name="line294" />294 ALBUM_RDOC = "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."
-</span><span class="marked1"><a name="line295" />295 TRACKNUM_RDOC = "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."
-</span><span class="marked0"><a name="line296" />296 DURATION_RDOC = "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."
-</span><span class="marked1"><a name="line297" />297 EXTENSION_RDOC = "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."
-</span><span class="marked0"><a name="line298" />298 LINK_REL_RDOC = "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."
-</span><span class="marked1"><a name="line299" />299 LINK_CONTENT_RDOC = "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."
-</span><span class="marked0"><a name="line300" />300 META_REL_RDOC = "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."
-</span><span class="marked1"><a name="line301" />301 META_CONTENT_RDOC = "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."
-</span><span class="inferred0"><a name="line302" />302
-</span><span class="marked1"><a name="line303" />303 ELEMENTS.each do |element|
-</span><span class="marked0"><a name="line304" />304 MetaGen.add_method( self, element, "@track.elements['#{element}'].text", eval(element.upcase + '_RDOC').to_s )
-</span><span class="inferred1"><a name="line305" />305 end
-</span><span class="inferred0"><a name="line306" />306
-</span><span class="marked1"><a name="line307" />307 ATTRIBUTE_AND_ELEMENT.each do |ae|
-</span><span class="marked0"><a name="line308" />308 MetaGen.add_method( self, "#{ae}_content", "@track.elements['#{ae}'].text", eval(ae.upcase + '_CONTENT_RDOC').to_s )
-</span><span class="marked1"><a name="line309" />309 MetaGen.add_method( self, "#{ae}_rel", "@track.elements['#{ae}'].attributes['rel']", eval(ae.upcase + '_REL_RDOC').to_s )
-</span><span class="inferred0"><a name="line310" />310 end
-</span><span class="inferred1"><a name="line311" />311
-</span><span class="inferred0"><a name="line312" />312 # :startdoc:
-</span><span class="inferred1"><a name="line313" />313
-</span><span class="inferred0"><a name="line314" />314 # Creates a XSPF::Track object from a <track> section of the XSPF document
-</span><span class="marked1"><a name="line315" />315 def initialize(tr)
-</span><span class="marked0"><a name="line316" />316 @track = tr
-</span><span class="marked1"><a name="line317" />317 end
-</span><span class="inferred0"><a name="line318" />318
-</span><span class="inferred1"><a name="line319" />319 end
+</span><span class="marked0"><a name="line278" />278 def tracklist=(value)
+</span><span class="marked1"><a name="line279" />279 raise(TypeError, 'The tracklist must be an instance of XSPF::Tracklist') unless value.instance_of?(XSPF::Tracklist)
+</span><span class="marked0"><a name="line280" />280 @tracklist = value
+</span><span class="inferred1"><a name="line281" />281 end
+</span><span class="inferred0"><a name="line282" />282
+</span><span class="marked1"><a name="line283" />283 alias :<< :tracklist=
+</span><span class="inferred0"><a name="line284" />284
+</span><span class="inferred1"><a name="line285" />285 # Exports the XSPF::Playlist to XML (only the <playlist> section)
+</span><span class="marked0"><a name="line286" />286 def to_xml
+</span><span class="inferred1"><a name="line287" />287
+</span><span class="marked0"><a name="line288" />288 xml = REXML::Element.new('playlist')
+</span><span class="inferred1"><a name="line289" />289
+</span><span class="marked0"><a name="line290" />290 ATTRIBUTES.each do |attrib|
+</span><span class="inferred1"><a name="line291" />291 # TODO Sure there is a nicer way to do evaluate this condition...
+</span><span class="marked0"><a name="line292" />292 unless eval('@' + attrib.downcase + '.nil?')
+</span><span class="marked1"><a name="line293" />293 xml.attributes[attrib] = eval('@' + attrib.downcase)
+</span><span class="inferred0"><a name="line294" />294 end
+</span><span class="inferred1"><a name="line295" />295 end
+</span><span class="inferred0"><a name="line296" />296
+</span><span class="marked1"><a name="line297" />297 ELEMENTS.each do |element|
+</span><span class="inferred0"><a name="line298" />298 # TODO Sure there is a nicer way to do evaluate this condition...
+</span><span class="marked1"><a name="line299" />299 unless eval('@' + element.downcase + '.nil?')
+</span><span class="marked0"><a name="line300" />300 el = REXML::Element.new(element)
+</span><span class="marked1"><a name="line301" />301 el.add_text( eval('@' + element.downcase) )
+</span><span class="marked0"><a name="line302" />302 xml.add_element(el)
+</span><span class="inferred1"><a name="line303" />303 end
+</span><span class="inferred0"><a name="line304" />304 end
+</span><span class="inferred1"><a name="line305" />305
+</span><span class="marked0"><a name="line306" />306 ATTRIBUTE_AND_ELEMENT.each do |ae|
+</span><span class="inferred1"><a name="line307" />307 # TODO Sure there is a nicer way to do evaluate this condition...
+</span><span class="marked0"><a name="line308" />308 unless eval('@' + ae.downcase + '_rel.nil? && @'+ ae.downcase + '_content.nil?')
+</span><span class="marked1"><a name="line309" />309 el = REXML::Element.new(ae.downcase)
+</span><span class="marked0"><a name="line310" />310 el.add_attribute('rel', eval('@' + ae.downcase + '_rel') )
+</span><span class="marked1"><a name="line311" />311 el.add_text( eval('@' + ae.downcase + '_content') )
+</span><span class="marked0"><a name="line312" />312 xml.add_element(el)
+</span><span class="inferred1"><a name="line313" />313 end
+</span><span class="inferred0"><a name="line314" />314 end
+</span><span class="inferred1"><a name="line315" />315
+</span><span class="marked0"><a name="line316" />316 xml << REXML::Document.new(@tracklist.to_xml)
+</span><span class="inferred1"><a name="line317" />317
+</span><span class="marked0"><a name="line318" />318 xml.to_s
+</span><span class="inferred1"><a name="line319" />319
+</span><span class="inferred0"><a name="line320" />320 end
+</span><span class="inferred1"><a name="line321" />321
+</span><span class="inferred0"><a name="line322" />322 # The <trackList> section of the XSPF document (outputs XML code). This method is only used while parsing.
+</span><span class="marked1"><a name="line323" />323 protected
+</span><span class="marked0"><a name="line324" />324 def tracklist_xml
+</span><span class="marked1"><a name="line325" />325 @playlist.elements['trackList']
+</span><span class="marked0"><a name="line326" />326 end
+</span><span class="inferred1"><a name="line327" />327
+</span><span class="marked0"><a name="line328" />328 private
+</span><span class="marked1"><a name="line329" />329 def add_instance_variable(hash, var)
+</span><span class="inferred0"><a name="line330" />330
+</span><span class="marked1"><a name="line331" />331 if !hash.nil? && hash.has_key?(var.downcase.to_sym)
+</span><span class="marked0"><a name="line332" />332 eval('@' + var.downcase + ' = \'' + hash[var.downcase.to_sym] + '\'')
+</span><span class="inferred1"><a name="line333" />333 else
+</span><span class="marked0"><a name="line334" />334 eval('@' + var.downcase + ' = defined?(' + var.upcase + '_DEFAULT) ? ' + var.upcase + '_DEFAULT : nil')
+</span><span class="inferred1"><a name="line335" />335 end
+</span><span class="inferred0"><a name="line336" />336
+</span><span class="marked1"><a name="line337" />337 end
+</span><span class="inferred0"><a name="line338" />338
+</span><span class="inferred1"><a name="line339" />339 end
+</span><span class="inferred0"><a name="line340" />340
+</span><span class="marked1"><a name="line341" />341 class XSPF::Tracklist < XSPF::Playlist
+</span><span class="inferred0"><a name="line342" />342
+</span><span class="marked1"><a name="line343" />343 attr_reader :tracklist
+</span><span class="inferred0"><a name="line344" />344
+</span><span class="inferred1"><a name="line345" />345 # Creates a XSPF::Tracklist from a XSPF::Playlist (parse mode) or without parameters (generation mode)
+</span><span class="marked0"><a name="line346" />346 def initialize(playlist=nil)
+</span><span class="marked1"><a name="line347" />347 if (playlist.instance_of?(Hash) || playlist.nil?) then
+</span><span class="marked0"><a name="line348" />348 @tracklist = ''
+</span><span class="marked1"><a name="line349" />349 @tracks = []
+</span><span class="inferred0"><a name="line350" />350 else
+</span><span class="marked1"><a name="line351" />351 @tracklist = playlist.tracklist_xml
+</span><span class="marked0"><a name="line352" />352 @tracks = @tracklist.elements.collect { |track| XSPF::Track.new(track) }
+</span><span class="inferred1"><a name="line353" />353 end
+</span><span class="marked0"><a name="line354" />354 end
+</span><span class="inferred1"><a name="line355" />355
+</span><span class="inferred0"><a name="line356" />356 # Returns an array XSPF::Track objects
+</span><span class="marked1"><a name="line357" />357 def tracks
+</span><span class="marked0"><a name="line358" />358 @tracks
+</span><span class="marked1"><a name="line359" />359 end
+</span><span class="inferred0"><a name="line360" />360
+</span><span class="inferred1"><a name="line361" />361 # Adds a new XSPF::Track to the XSPF::Tracklist
+</span><span class="marked0"><a name="line362" />362 def <<(track)
+</span><span class="marked1"><a name="line363" />363 @tracks << track
+</span><span class="marked0"><a name="line364" />364 end
+</span><span class="inferred1"><a name="line365" />365
+</span><span class="inferred0"><a name="line366" />366 # Exports the XSPF::Tracklist to XML (only the <trackList> section)
+</span><span class="marked1"><a name="line367" />367 def to_xml
+</span><span class="marked0"><a name="line368" />368 xml = REXML::Element.new('trackList')
+</span><span class="marked1"><a name="line369" />369 @tracks.each { |t| xml << REXML::Document.new(t.to_xml) }
+</span><span class="marked0"><a name="line370" />370 xml.to_s
+</span><span class="inferred1"><a name="line371" />371 end
+</span><span class="inferred0"><a name="line372" />372
+</span><span class="inferred1"><a name="line373" />373 end
+</span><span class="inferred0"><a name="line374" />374
+</span><span class="marked1"><a name="line375" />375 class XSPF::Track
+</span><span class="inferred0"><a name="line376" />376
+</span><span class="marked1"><a name="line377" />377 attr_reader :track
+</span><span class="inferred0"><a name="line378" />378
+</span><span class="inferred1"><a name="line379" />379 #:stopdoc:
+</span><span class="marked0"><a name="line380" />380 ELEMENTS = %w{ location identifier title creator annotation info image album trackNum duration extension }
+</span><span class="marked1"><a name="line381" />381 ATTRIBUTE_AND_ELEMENT = %w{ link meta }
+</span><span class="inferred0"><a name="line382" />382
+</span><span class="marked1"><a name="line383" />383 LOCATION_RDOC = '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.'
+</span><span class="marked0"><a name="line384" />384 IDENTIFIER_RDOC = '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.'
+</span><span class="marked1"><a name="line385" />385 TITLE_RDOC = '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.'
+</span><span class="marked0"><a name="line386" />386 CREATOR_RDOC = '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.'
+</span><span class="marked1"><a name="line387" />387 ANNOTATION_RDOC = '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.'
+</span><span class="marked0"><a name="line388" />388 INFO_RDOC = 'URL of a place where this resource can be bought or more info can be found.'
+</span><span class="marked1"><a name="line389" />389 IMAGE_RDOC = 'URL of an image to display for the duration of the track. XSPF::Track objects MAY contain exactly one.'
+</span><span class="marked0"><a name="line390" />390 ALBUM_RDOC = '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.'
+</span><span class="marked1"><a name="line391" />391 TRACKNUM_RDOC = '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.'
+</span><span class="marked0"><a name="line392" />392 DURATION_RDOC = '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.'
+</span><span class="marked1"><a name="line393" />393 EXTENSION_RDOC = '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.'
+</span><span class="marked0"><a name="line394" />394 LINK_REL_RDOC = '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.'
+</span><span class="marked1"><a name="line395" />395 LINK_CONTENT_RDOC = '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.'
+</span><span class="marked0"><a name="line396" />396 META_REL_RDOC = '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.'
+</span><span class="marked1"><a name="line397" />397 META_CONTENT_RDOC = '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.'
+</span><span class="inferred0"><a name="line398" />398
+</span><span class="marked1"><a name="line399" />399 ELEMENTS.each do |element|
+</span><span class="marked0"><a name="line400" />400 MetaGen.add_method( self, element, "@track.elements['#{element}'].text", eval(element.upcase + '_RDOC').to_s )
+</span><span class="inferred1"><a name="line401" />401 end
+</span><span class="inferred0"><a name="line402" />402
+</span><span class="marked1"><a name="line403" />403 ATTRIBUTE_AND_ELEMENT.each do |ae|
+</span><span class="marked0"><a name="line404" />404 MetaGen.add_method( self, "#{ae}_content", "@track.elements['#{ae}'].text", eval(ae.upcase + '_CONTENT_RDOC').to_s )
+</span><span class="marked1"><a name="line405" />405 MetaGen.add_method( self, "#{ae}_rel", "@track.elements['#{ae}'].attributes['rel']", eval(ae.upcase + '_REL_RDOC').to_s )
+</span><span class="inferred0"><a name="line406" />406 end
+</span><span class="inferred1"><a name="line407" />407
+</span><span class="inferred0"><a name="line408" />408 # :startdoc:
+</span><span class="inferred1"><a name="line409" />409
+</span><span class="inferred0"><a name="line410" />410 # Creates a XSPF::Track object from a <track> section of the XSPF document or from a hash of values
+</span><span class="inferred1"><a name="line411" />411 #
+</span><span class="inferred0"><a name="line412" />412 # Possible keys in the hash in generation mode: :location, :identifier, :title, :creator, :annotation, :info, :image, :album, :tracknum, :duration, :extension, :link_rel, :link_content, :meta_rel, :meta_content)
+</span><span class="marked1"><a name="line413" />413 def initialize(tr)
+</span><span class="inferred0"><a name="line414" />414
+</span><span class="marked1"><a name="line415" />415 if tr.instance_of?(Hash)
+</span><span class="inferred0"><a name="line416" />416
+</span><span class="marked1"><a name="line417" />417 ELEMENTS.each do |element|
+</span><span class="marked0"><a name="line418" />418 add_instance_variable(tr, element.downcase)
+</span><span class="inferred1"><a name="line419" />419 end
+</span><span class="inferred0"><a name="line420" />420
+</span><span class="marked1"><a name="line421" />421 ATTRIBUTE_AND_ELEMENT.each do |ae|
+</span><span class="marked0"><a name="line422" />422 add_instance_variable(tr, "#{ae.downcase}_content" )
+</span><span class="marked1"><a name="line423" />423 add_instance_variable(tr, "#{ae.downcase}_rel" )
+</span><span class="inferred0"><a name="line424" />424 end
+</span><span class="inferred1"><a name="line425" />425
+</span><span class="inferred0"><a name="line426" />426 else
+</span><span class="marked1"><a name="line427" />427 @track = tr
+</span><span class="inferred0"><a name="line428" />428
+</span><span class="marked1"><a name="line429" />429 ELEMENTS.each do |element|
+</span><span class="marked0"><a name="line430" />430 eval('@' + element.downcase + '= parse_' + element.downcase)
+</span><span class="inferred1"><a name="line431" />431 end
+</span><span class="inferred0"><a name="line432" />432
+</span><span class="marked1"><a name="line433" />433 ATTRIBUTE_AND_ELEMENT.each do |ae|
+</span><span class="marked0"><a name="line434" />434 eval('@' + ae.downcase + '_content = parse_' + ae.downcase + '_content')
+</span><span class="marked1"><a name="line435" />435 eval('@' + ae.downcase + '_rel = parse_' + ae.downcase + '_rel')
+</span><span class="inferred0"><a name="line436" />436 end
+</span><span class="inferred1"><a name="line437" />437 end
+</span><span class="inferred0"><a name="line438" />438
+</span><span class="marked1"><a name="line439" />439 end
+</span><span class="inferred0"><a name="line440" />440
+</span><span class="inferred1"><a name="line441" />441 # Exports the XSPF::Track to XML (only the <track> section)
+</span><span class="marked0"><a name="line442" />442 def to_xml
+</span><span class="inferred1"><a name="line443" />443
+</span><span class="marked0"><a name="line444" />444 xml = REXML::Element.new('track')
+</span><span class="inferred1"><a name="line445" />445
+</span><span class="marked0"><a name="line446" />446 ELEMENTS.each do |element|
+</span><span class="inferred1"><a name="line447" />447 # TODO Sure there is a nicer way to do evaluate this condition...
+</span><span class="marked0"><a name="line448" />448 unless eval('@' + element.downcase + '.nil?')
+</span><span class="marked1"><a name="line449" />449 el = REXML::Element.new(element)
+</span><span class="marked0"><a name="line450" />450 el.add_text( eval('@' + element.downcase) )
+</span><span class="marked1"><a name="line451" />451 xml.add_element(el)
+</span><span class="inferred0"><a name="line452" />452 end
+</span><span class="inferred1"><a name="line453" />453 end
+</span><span class="inferred0"><a name="line454" />454
+</span><span class="marked1"><a name="line455" />455 ATTRIBUTE_AND_ELEMENT.each do |ae|
+</span><span class="inferred0"><a name="line456" />456 # TODO Sure there is a nicer way to do evaluate this condition...
+</span><span class="marked1"><a name="line457" />457 unless eval('@' + ae.downcase + '_rel.nil? && @'+ ae.downcase + '_content.nil?')
+</span><span class="marked0"><a name="line458" />458 el = REXML::Element.new(ae.downcase)
+</span><span class="marked1"><a name="line459" />459 el.add_attribute('rel', eval('@' + ae.downcase + '_rel') )
+</span><span class="marked0"><a name="line460" />460 el.add_text( eval('@' + ae.downcase + '_content') )
+</span><span class="marked1"><a name="line461" />461 xml.add_element(el)
+</span><span class="inferred0"><a name="line462" />462 end
+</span><span class="inferred1"><a name="line463" />463 end
+</span><span class="inferred0"><a name="line464" />464
+</span><span class="marked1"><a name="line465" />465 xml.to_s
+</span><span class="inferred0"><a name="line466" />466
+</span><span class="inferred1"><a name="line467" />467 end
+</span><span class="inferred0"><a name="line468" />468
+</span><span class="marked1"><a name="line469" />469 private
+</span><span class="marked0"><a name="line470" />470 def add_instance_variable(hash, var)
+</span><span class="inferred1"><a name="line471" />471
+</span><span class="marked0"><a name="line472" />472 if hash.has_key?(var.downcase.to_sym)
+</span><span class="marked1"><a name="line473" />473 eval('@' + var.downcase + ' = \'' + hash[var.downcase.to_sym] + '\'')
+</span><span class="inferred0"><a name="line474" />474 else
+</span><span class="marked1"><a name="line475" />475 eval('@' + var.downcase + ' = defined?(' + var.upcase + '_DEFAULT) ? ' + var.upcase + '_DEFAULT : nil')
+</span><span class="inferred0"><a name="line476" />476 end
+</span><span class="inferred1"><a name="line477" />477
+</span><span class="marked0"><a name="line478" />478 end
+</span><span class="inferred1"><a name="line479" />479
+</span><span class="inferred0"><a name="line480" />480 end
</span></pre><hr /> <p>Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'>rcov code coverage analysis tool for Ruby</a> version 0.7.0.</p><p>
<a href='http://validator.w3.org/check/referer'>
<img src='http://www.w3.org/Icons/valid-xhtml10' height='31' alt='Valid XHTML 1.0!' width='88' />
</a>
<a href='http://jigsaw.w3.org/css-validator/check/referer'>