module Ayril::XMLElement::ElementAttributeManipulation
Public Instance Methods
attribute()
click to toggle source
# File lib/ayril/xml_element/element_attribute_manipulation.rb, line 24 def attribute @attributes.nil? ? (@attributes = XMLElement::XMLAttributeHash.new self) : @attributes end
Also aliased as: attr
attribute=(hash)
click to toggle source
# File lib/ayril/xml_element/element_attribute_manipulation.rb, line 29 def attribute=(hash); self.setAttributesAsDictionary hash end
has_attribute?(k)
click to toggle source
# File lib/ayril/xml_element/element_attribute_manipulation.rb, line 57 def has_attribute?(k); not self.attributeForName(k.to_s).nil? end
read_attribute(k)
click to toggle source
# File lib/ayril/xml_element/element_attribute_manipulation.rb, line 33 def read_attribute(k); self.attributeForName(k.to_s).maybe(:stringValue) end
Also aliased as: get_attribute, []
remove_attribute(a)
click to toggle source
# File lib/ayril/xml_element/element_attribute_manipulation.rb, line 54 def remove_attribute(a) self.removeAttributeForName(a.to_s); self.sync end
Also aliased as: delete_attribute
write_attribute(k, v=nil)
click to toggle source
# File lib/ayril/xml_element/element_attribute_manipulation.rb, line 37 def write_attribute(k, v=nil) if v.nil? and k.kind_of? Hash k.each { |a, b| self.write_attribute a.to_s, b } unless k.empty? return self end attr = self.attributeForName(k) if attr.nil? self.addAttribute XMLNode.attributeWithName(k.to_s, stringValue: v) else attr.stringValue = v end self end