module Ayril::XMLElement::ElementAttributeManipulation

Public Instance Methods

[](k)
Alias for: read_attribute
[]=(k, v=nil)
Alias for: write_attribute
add_attribute(k, v=nil)
Alias for: write_attribute
attr()
Alias for: attribute
attr=(hash)
Alias for: attribute=
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
Also aliased as: attr=, set
delete_attribute(a)
Alias for: remove_attribute
get_attribute(k)
Alias for: read_attribute
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
set(hash)
Alias for: attribute=
set_attribute(k, v=nil)
Alias for: write_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
Also aliased as: add_attribute, set_attribute, []=