class NOMS::XmlHash
Attributes
element[RW]
name[RW]
Public Class Methods
new(el)
click to toggle source
Calls superclass method
# File lib/noms/httpclient.rb, line 48 def initialize(el) super @element = el @name = el.name self['text'] = el.text el.attributes.each do |attr, value| self[attr] = value end self['children'] = [] el.elements.each do |child| self['children'] << NOMS::XmlHash.new(child) end end
Public Instance Methods
to_xml(name=nil)
click to toggle source
# File lib/noms/httpclient.rb, line 62 def to_xml(name=nil) el = REXML::Element.new(name || self.name) el.text = self['text'] if self.has_key? 'text' self.each do |key, val| next if ['children', 'text'].include? key el.add_attribute(key, val) end if self.has_key? 'children' self['children'].each do |child| el.add_element child.to_xml end end el end