class XML::Smart::Dom::NodeSet

Public Class Methods

new(nodeset) click to toggle source
# File lib/xml/smart_domnodeset.rb, line 8
def initialize(nodeset)
  @nodeset = nodeset
end

Public Instance Methods

===(cls) click to toggle source
# File lib/xml/smart_domnodeset.rb, line 12
def ===(cls); self.is_a? cls; end
[](*a) click to toggle source
# File lib/xml/smart_domnodeset.rb, line 17
def [](*a);  Dom::smart_helper(@nodeset[*a]); end
at(*a) click to toggle source
# File lib/xml/smart_domnodeset.rb, line 16
def at(*a);  Dom::smart_helper(@nodeset[*a]); end
delete_all!() click to toggle source
# File lib/xml/smart_domnodeset.rb, line 21
def delete_all!;  @nodeset.remove; @nodeset.to_a.each { |n| @nodeset.delete(n) }; true  end
delete_at(*a) click to toggle source
# File lib/xml/smart_domnodeset.rb, line 31
def delete_at(*a)
  tmp = @nodeset[*a]
  case tmp
    when Nokogiri::XML::NodeSet
      tmp.each { |node| @nodeset.delete(node.remove) }
      true
    when Nokogiri::XML::Node
      @nodeset.delete(tmp.remove)
      true
    else
      false
  end
end
delete_if(&block) click to toggle source
# File lib/xml/smart_domnodeset.rb, line 45
def delete_if(&block) 
  return self if block.nil?
  tmp = []
  @nodeset.each do |node| 
    if block.call(Dom::smart_helper(node))
      tmp << node.remove
    end  
  end    
  tmp.each { |t| @nodeset.delete(t) }
  self
end
each(&block) click to toggle source
# File lib/xml/smart_domnodeset.rb, line 23
def each(&block) 
  return self if block.nil?
  @nodeset.each do |node| 
    block.call Dom::smart_helper(node)
  end
  self
end
empty?() click to toggle source
# File lib/xml/smart_domnodeset.rb, line 20
def empty?;       @nodeset.empty?; end
first() click to toggle source
# File lib/xml/smart_domnodeset.rb, line 14
def first;        Dom::smart_helper(@nodeset.first); end
last() click to toggle source
# File lib/xml/smart_domnodeset.rb, line 15
def last;         Dom::smart_helper(@nodeset.last); end
length() click to toggle source
# File lib/xml/smart_domnodeset.rb, line 19
def length;       @nodeset.length; end