C0 code coverage information

Generated on Sun Dec 03 14:34:00 CET 2006 with rcov 0.7.0


Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
lib/xspf.rb 481 322
100.0% 
100.0% 
  1 #--
  2 # =============================================================================
  3 # Copyright (c) 2006 Pau Garcia i Quiles (pgquiles@elpauer.org)
  4 # All rights reserved.
  5 #
  6 # This library may be used only as allowed by either the Ruby license (or, by
  7 # association with the Ruby license, the GPL). See the "doc" subdirectory of
  8 # the XSPF distribution for the texts of these licenses.
  9 # -----------------------------------------------------------------------------
 10 # XSPF for Ruby website : http://xspf.rubyforge.org
 11 # =============================================================================
 12 #++
 13 
 14 require 'rexml/document'
 15 require 'xml/xslt'
 16 
 17 # :include: USAGE
 18 # :main: USAGE
 19 
 20 module MetaGen #:nodoc:
 21 
 22   # define the method
 23   def self.add_method(klass, meth_name, body, meth_rdoc)
 24     code = <<-CODE
 25     # #{meth_rdoc}
 26     def #{meth_name.downcase}
 27       @#{meth_name}
 28     end
 29     
 30     def #{meth_name.downcase}=(value)
 31       @#{meth_name.downcase} = value
 32     end
 33 
 34     private
 35     def parse_#{meth_name.downcase}
 36       begin
 37         #{body}
 38       rescue NoMethodError
 39         return nil
 40       end
 41     end
 42     CODE
 43     
 44     klass.module_eval(code)
 45  
 46     # hook to write klass + name attrib to a file
 47     if $META_RDOC
 48       open($META_RDOC, 'a+') do |f|
 49         f.puts("class #{klass}\n #{code}\n end")
 50       end
 51     end
 52     
 53   end
 54 
 55   # output in different formats
 56   # FIXME Only works in parse mode, not in generation mode. 
 57   def self.add_output_format(klass, format, meth_rdoc)
 58     xslt_path = "'#{File.join( File.dirname(__FILE__), %Q{xspf2#{format}.xsl} )}'"
 59     code = <<-CODE
 60       # #{meth_rdoc}
 61       def to_#{format}
 62         xslt = XML::XSLT.new
 63         xslt.xml = self.to_xml
 64         xslt.xsl = REXML::Document.new( File.new( #{xslt_path} ) )
 65         xslt.serve
 66       end
 67     CODE
 68     
 69     klass.module_eval(code)
 70    
 71     if $META_RDOC
 72       open($META_RDOC, 'a+') do |f|
 73         f.puts("class #{klass}\n #{code}\n end")
 74       end
 75     end
 76 
 77   end
 78   
 79 end
 80 
 81 class XSPF
 82 
 83   attr_reader :xspf
 84 
 85   #:stopdoc:
 86   ATTRIBUTES = %w{ version encoding }
 87   VERSION_RDOC = 'Version for the XML document or _nil_ if not defined'
 88   ENCODING_RDOC = 'Encoding of the XML document or _nil_ if not defined'
 89   
 90   OUTPUT_FORMATS = %w{ m3u html smil rdf soundblox }
 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.'
 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.'
 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.'
 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.'
 95   RDF_RDOC = 'Creates a RDF feed from the XSPF document. This method makes use of the XSPF to RDF XSLT transformation by Libby Miller.'
 96 
 97   ATTRIBUTES.each do |attrib|
 98     MetaGen.add_method(self, attrib, "@xspf.#{attrib}", eval(attrib.upcase + '_RDOC').to_s )
 99   end
100 
101   OUTPUT_FORMATS.each do |format|
102     MetaGen.add_output_format(self, format, eval(format.upcase + '_RDOC').to_s )
103   end
104 
105   #:startdoc:
106   
107   # Creates a XSPF object from a file or string (parse mode) or from a hash or nil (generation mode).
108   #
109   # Possible keys in the hash: :version, :encoding
110   def initialize(source = nil)
111     if ( source.nil? || source.instance_of?(Hash) ) then
112         @version = if source.nil? || !source.has_key?(:version)
113                      '1.0'
114                    else
115                      source[:version]
116                    end
117         @encoding = if source.nil? || !source.has_key?(:encoding)
118                       'UTF-8'
119                     else
120                       source[:encoding]
121                     end
122         @playlist = nil
123         @playlist = if !source.nil? && source.has_key?(:playlist) then
124                         if source[:playlist].instance_of?(XSPF::Playlist)
125                             source[:playlist]
126                         else
127                           raise(TypeError, 'You must pass a file/string (parsing mode) or a hash/nothing (generator mode) as argument to XSPF#new')
128                         end
129                     end
130 
131     elsif ( source.instance_of?(File) || source.instance_of?(String) ) then
132         @xspf = REXML::Document.new(source)
133         ATTRIBUTES.each do |attrib|
134           eval('@' + attrib + '= parse_' + attrib)
135         end
136 
137         @playlist = XSPF::Playlist.new(self)
138         
139     else
140       raise(TypeError, 'You must pass a file/string (parsing mode) or a hash/nothing (generator mode) as argument to XSPF#new')
141     end
142   end
143 
144   # A XSPF::Playlist object
145   def playlist
146     @playlist
147   end
148 
149   def playlist=(value)
150     raise(TypeError, 'The playlist must be an instance of XSPF::Playlist') unless value.instance_of?(XSPF::Playlist)
151     @playlist = value
152   end
153 
154   # Exports the XSPF object to XML
155   def to_xml
156     xml = REXML::Document.new
157     xml << REXML::XMLDecl.new(@version, @encoding)
158     xml << REXML::Document.new(@playlist.to_xml) unless @playlist.nil?
159     xml.to_s
160   end
161 
162   # The <playlist> section of the XSPF document (outputs XML code). This method is only used while parsing.
163   protected
164   def playlist_xml
165     @xspf.root
166   end
167 
168 end
169 
170 class XSPF::Playlist < XSPF
171 
172   attr_reader :playlist
173 
174   #:stopdoc:
175   ATTRIBUTES = %w{ xmlns version }
176   ELEMENTS = %w{ title creator annotation info location identifier image date license attribution extension }
177   ATTRIBUTE_AND_ELEMENT = %w{ link meta }
178   ATTRIBUTION_CHILD_ELEMENTS = %w{ location identifier }
179   EXTENSION_CHILD_ELEMENTS = %w{ application content }
180   
181   XMLNS_RDOC = 'The XML namespace. It must be http://xspf.org/ns/0/ for a valid XSPF document.'
182   XMLNS_DEFAULT = 'http://xspf.org/ns/0/'
183   VERSION_RDOC = 'The XSPF version. It may be 0 or 1, although 1 is strongly advised.'
184   VERSION_DEFAULT = '1'
185   TITLE_RDOC = 'A human-readable title for the playlist. xspf:playlist elements MAY contain exactly one.'
186   CREATOR_RDOC = 'Human-readable name of the entity (author, authors, group, company, etc) that authored the playlist. XSPF::Playlist objects MAY contain exactly one.'
187   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.'
188   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.'
189   LOCATION_RDOC = 'Source URL for this playlist. XSPF::Playlist objects MAY contain exactly one.'
190   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.'
191   IMAGE_RDOC = 'URL of an image to display if XSPF::Playlist#image return nil. XSPF::Playlist objects MAY contain exactly one.'
192   DATE_RDOC = 'Creation date (not last-modified date) of the playlist, formatted as a XML schema dateTime. XSPF::Playlist objects MAY contain exactly one.'
193   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.'
194   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.'
195   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.'
196   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.'
197   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.'
198   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.'
199   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.'
200   
201 # FIXME Currently we only return the first "link"
202 # FIXME Currently we only return the first "meta"
203 # FIXME Currently we only return the first "extension"
204 # TODO Parse "attribution"
205 # TODO Parse "extension"
206 
207   # Returns the value of the attribute or nil if the attribute is not present
208   ATTRIBUTES.each do |attrib|
209     MetaGen.add_method( self, attrib, "@playlist.root.attributes['#{attrib}']", eval(attrib.upcase + '_RDOC').to_s )
210   end
211 
212   ELEMENTS.each do |element|
213     MetaGen.add_method( self, element, "@playlist.elements['#{element}'].text", eval(element.upcase + '_RDOC').to_s )
214   end
215 
216   ATTRIBUTE_AND_ELEMENT.each do |ae|
217     MetaGen.add_method( self, "#{ae}_content", "@playlist.elements['#{ae}'].text", eval(ae.upcase + '_CONTENT_RDOC').to_s )
218     MetaGen.add_method( self, "#{ae}_rel", "@playlist.elements['#{ae}'].attributes['rel']", eval(ae.upcase + '_REL_RDOC').to_s )
219   end
220 
221   #:startdoc:
222   
223   # Creates a XSPF::Playlist from a XSPF document (parse mode) or from a hash of values (generation mode)
224   #
225   # 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
226   def initialize(source = nil)
227 
228     if ( source.instance_of?(Hash) || source.nil? ) then
229 
230       ATTRIBUTES.each do |attrib|
231         add_instance_variable(source, attrib)
232       end
233 
234       ELEMENTS.each do |element|
235         add_instance_variable(source, element)
236       end
237 
238       ATTRIBUTE_AND_ELEMENT.each do |ae|
239         add_instance_variable(source, "#{ae}_content" )
240         add_instance_variable(source, "#{ae}_rel" )
241       end
242 
243       @tracklist = if ( !source.nil? && source.has_key?(:tracklist) && source[:tracklist].instance_of?(XSPF::Tracklist) )
244                       source[:tracklist]
245                     else
246                       nil
247                     end
248 
249     elsif source.instance_of?(XSPF) then
250 
251       @playlist = source.playlist_xml
252 
253       ATTRIBUTES.each do |attrib|
254         eval('@' + attrib.downcase + '= parse_' + attrib.downcase)
255       end
256   
257       ELEMENTS.each do |element|
258         eval('@' + element.downcase + '= parse_' + element.downcase)
259       end
260 
261       ATTRIBUTE_AND_ELEMENT.each do |ae|
262         eval('@' + ae.downcase + '_content = parse_' + ae.downcase + '_content')
263         eval('@' + ae.downcase + '_rel = parse_' + ae.downcase + '_rel')
264       end
265 
266       @tracklist = XSPF::Tracklist.new(self)
267 
268     else
269       raise(TypeError, 'You must pass a XSPF object (parsing mode) or a hash (generator mode) as argument to XSPF::Playlist#new')
270     end
271     
272   end
273 
274   # A XSPF::Tracklist object
275   def tracklist
276     @tracklist
277   end
278 
279   def tracklist=(value)
280     raise(TypeError, 'The tracklist must be an instance of XSPF::Tracklist') unless value.instance_of?(XSPF::Tracklist)
281     @tracklist = value
282   end
283 
284   alias :<< :tracklist=
285 
286   # Exports the XSPF::Playlist to XML (only the <playlist> section)
287   def to_xml
288   
289     xml = REXML::Element.new('playlist')
290 
291     ATTRIBUTES.each do |attrib|
292       # TODO Sure there is a nicer way to do evaluate this condition...
293       unless eval('@' + attrib.downcase + '.nil?')
294         xml.attributes[attrib] = eval('@' + attrib.downcase)
295       end 
296     end
297     
298     ELEMENTS.each do |element|
299       # TODO Sure there is a nicer way to do evaluate this condition...
300       unless eval('@' + element.downcase + '.nil?')
301         el = REXML::Element.new(element)
302         el.add_text( eval('@' + element.downcase) )
303         xml.add_element(el)
304       end 
305     end
306 
307     ATTRIBUTE_AND_ELEMENT.each do |ae|
308       # TODO Sure there is a nicer way to do evaluate this condition...
309       unless eval('@' + ae.downcase + '_rel.nil? && @'+ ae.downcase + '_content.nil?')
310         el = REXML::Element.new(ae.downcase)
311         el.add_attribute('rel', eval('@' + ae.downcase + '_rel') )
312         el.add_text( eval('@' + ae.downcase + '_content') )
313         xml.add_element(el)
314       end 
315     end
316 
317     xml << REXML::Document.new(@tracklist.to_xml)
318     
319     xml.to_s
320   
321   end
322   
323   # The <trackList> section of the XSPF document (outputs XML code). This method is only used while parsing.
324   protected
325   def tracklist_xml  
326     @playlist.elements['trackList']
327   end
328 
329   private
330   def add_instance_variable(hash, var)
331 
332     if !hash.nil? && hash.has_key?(var.downcase.to_sym)
333       eval('@' + var.downcase + ' = \'' + hash[var.downcase.to_sym] + '\'')
334     else
335       eval('@' + var.downcase + ' = defined?(' + var.upcase + '_DEFAULT) ? ' + var.upcase + '_DEFAULT : nil')
336     end
337 
338   end
339 
340 end
341 
342 class XSPF::Tracklist < XSPF::Playlist
343 
344   attr_reader :tracklist
345 
346   # Creates a XSPF::Tracklist from a XSPF::Playlist (parse mode) or without parameters (generation mode)
347   def initialize(playlist=nil)
348     if (playlist.instance_of?(Hash) || playlist.nil?) then
349       @tracklist = ''
350       @tracks = []
351     else
352       @tracklist = playlist.tracklist_xml
353       @tracks = @tracklist.elements.collect { |track| XSPF::Track.new(track) }
354     end
355   end
356 
357   # Returns an array XSPF::Track objects
358   def tracks
359     @tracks
360   end
361 
362   # Adds a new XSPF::Track to the XSPF::Tracklist
363   def <<(track)
364     @tracks << track
365   end
366 
367   # Exports the XSPF::Tracklist to XML (only the <trackList> section)
368   def to_xml
369     xml = REXML::Element.new('trackList')
370     @tracks.each { |t| xml << REXML::Document.new(t.to_xml) }
371     xml.to_s
372   end
373 
374 end
375 
376 class XSPF::Track
377 
378   attr_reader :track
379 
380   #:stopdoc:
381   ELEMENTS = %w{ location identifier title creator annotation info image album trackNum duration extension }
382   ATTRIBUTE_AND_ELEMENT = %w{ link meta }
383   
384   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.'
385   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.'
386   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.'
387   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.'
388   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.'
389   INFO_RDOC = 'URL of a place where this resource can be bought or more info can be found.'
390   IMAGE_RDOC = 'URL of an image to display for the duration of the track. XSPF::Track objects MAY contain exactly one.'
391   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.'
392   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.'
393   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.'
394   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.'
395   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.'
396   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.'
397   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.'
398   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.'
399 
400   ELEMENTS.each do |element|
401     MetaGen.add_method( self, element, "@track.elements['#{element}'].text", eval(element.upcase + '_RDOC').to_s )
402   end
403 
404   ATTRIBUTE_AND_ELEMENT.each do |ae|
405     MetaGen.add_method( self, "#{ae}_content", "@track.elements['#{ae}'].text", eval(ae.upcase + '_CONTENT_RDOC').to_s )
406     MetaGen.add_method( self, "#{ae}_rel", "@track.elements['#{ae}'].attributes['rel']", eval(ae.upcase + '_REL_RDOC').to_s )
407   end
408 
409   # :startdoc:
410   
411   # Creates a XSPF::Track object from a <track> section of the XSPF document or from a hash of values
412   #
413   # 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)
414   def initialize(tr)
415     
416     if tr.instance_of?(Hash)
417 
418       ELEMENTS.each do |element|
419         add_instance_variable(tr, element.downcase)
420       end
421 
422       ATTRIBUTE_AND_ELEMENT.each do |ae|
423         add_instance_variable(tr, "#{ae.downcase}_content" )
424         add_instance_variable(tr, "#{ae.downcase}_rel" )
425       end
426       
427     else
428       @track = tr
429 
430       ELEMENTS.each do |element|
431         eval('@' + element.downcase + '= parse_' + element.downcase)
432       end
433 
434       ATTRIBUTE_AND_ELEMENT.each do |ae|
435         eval('@' + ae.downcase + '_content = parse_' + ae.downcase + '_content')
436         eval('@' + ae.downcase + '_rel = parse_' + ae.downcase + '_rel')
437       end
438     end
439     
440   end
441 
442   # Exports the XSPF::Track to XML (only the <track> section)
443   def to_xml
444 
445     xml = REXML::Element.new('track')
446     
447     ELEMENTS.each do |element|
448       # TODO Sure there is a nicer way to do evaluate this condition...
449       unless eval('@' + element.downcase + '.nil?')
450         el = REXML::Element.new(element)
451         el.add_text( eval('@' + element.downcase) )
452         xml.add_element(el)
453       end 
454     end
455 
456     ATTRIBUTE_AND_ELEMENT.each do |ae|
457       # TODO Sure there is a nicer way to do evaluate this condition...
458       unless eval('@' + ae.downcase + '_rel.nil? && @'+ ae.downcase + '_content.nil?')
459         el = REXML::Element.new(ae.downcase)
460         el.add_attribute('rel', eval('@' + ae.downcase + '_rel') )
461         el.add_text( eval('@' + ae.downcase + '_content') )
462         xml.add_element(el)
463       end 
464     end
465 
466     xml.to_s
467     
468   end
469   
470   private
471   def add_instance_variable(hash, var)
472     
473     if hash.has_key?(var.downcase.to_sym)
474       eval('@' + var.downcase + ' = \'' + hash[var.downcase.to_sym] + '\'')
475     else
476       eval('@' + var.downcase + ' = defined?(' + var.upcase + '_DEFAULT) ? ' + var.upcase + '_DEFAULT : nil')
477     end
478   
479   end
480 
481 end

Generated using the rcov code coverage analysis tool for Ruby version 0.7.0.

Valid XHTML 1.0! Valid CSS!