Class | Atom::Element |
In: |
lib/atom/yaml.rb
lib/atom/element.rb |
Parent: | Hash |
base | [RW] | this element’s xml:base |
extensions | [R] | a REXML::Element that shares this element’s extension attributes and child elements |
get the value of an attribute
# File lib/atom/element.rb, line 115 115: def [] key 116: test_key key 117: 118: super 119: end
set the value of an attribute
# File lib/atom/element.rb, line 122 122: def []= key, value 123: test_key key 124: 125: super 126: end
convert to a REXML::Element (with no namespace)
# File lib/atom/element.rb, line 147 147: def to_element 148: elem = REXML::Element.new(local_name) 149: 150: self.class.elements.each do |name,kind,req| 151: v = get(name) 152: next if v.nil? 153: 154: if v.respond_to? :to_element 155: e = v.to_element 156: e = [ e ] unless e.is_a? Array 157: 158: e.each do |bit| 159: elem << bit 160: end 161: else 162: e = REXML::Element.new(name.to_s, elem).text = get(name) 163: end 164: end 165: 166: self.class.attrs.each do |name,req| 167: value = self[name.to_s] 168: elem.attributes[name.to_s] = value if value 169: end 170: 171: self.extensions.children.each do |element| 172: elem << element.dup # otherwise they get removed from @extensions 173: end 174: 175: if self.base and not self.base.empty? 176: elem.attributes["xml:base"] = self.base 177: end 178: 179: elem 180: end