class XML::Smart::Dom::AttributeSet

Public Class Methods

new(element) click to toggle source
# File lib/xml/smart_domattributeset.rb, line 8
def initialize(element)
  @element = element
  @set = @element.attributes
end

Public Instance Methods

===(cls) click to toggle source
# File lib/xml/smart_domattributeset.rb, line 13
def ===(cls); self.is_a? cls; end
[](name,attr=false) click to toggle source
# File lib/xml/smart_domattributeset.rb, line 24
def [](name,attr=false)
  return nil unless has_attr?(name)
  if attr == false 
    @element.attribute(name).value
  else  
    Attribute.new(@element.attribute(name))
  end 
end
[]=(name,value) click to toggle source
# File lib/xml/smart_domattributeset.rb, line 32
def []=(name,value);
  @element[name] = value
end
attr?(a)
Alias for: has_attr?
delete_all!() click to toggle source
# File lib/xml/smart_domattributeset.rb, line 38
def delete_all!; @set.each { |k,a| a.remove }; end
delete_at!(name) click to toggle source
# File lib/xml/smart_domattributeset.rb, line 48
def delete_at!(name)
  tmp = @set[name]
  if tmp.is_a?(Nokogiri::XML::Attr)
    tmp.remove
    true
  else
    false
  end
end
delete_if!(&block) click to toggle source
# File lib/xml/smart_domattributeset.rb, line 58
def delete_if!(&block)
  return self if block.nil?
  @set.each do |k,node|
    node.remove if block.call(Dom::smart_helper(node))
  end
  self
end
each(&block) click to toggle source
# File lib/xml/smart_domattributeset.rb, line 40
def each(&block)
  return self if block.nil?
  @set.each do |k,node|
    block.call Dom::smart_helper(node)
  end
  self
end
empty?() click to toggle source
# File lib/xml/smart_domattributeset.rb, line 37
def empty?;      @set.empty?; end
has_attr?(a) click to toggle source
# File lib/xml/smart_domattributeset.rb, line 19
def has_attr?(a); @set.has_key?(a) end
Also aliased as: include?, attr?, member?
include?(a)
Alias for: has_attr?
length() click to toggle source
# File lib/xml/smart_domattributeset.rb, line 36
def length;      @set.length; end
member?(a)
Alias for: has_attr?
names() click to toggle source
# File lib/xml/smart_domattributeset.rb, line 15
def names
  @set.keys 
end