Class: XPath::XPathNodeSet::LocationStep

Inherits:
XPath::XPathNodeSet show all
Defined in:
lib/xml/xpath.rb

Instance Method Summary collapse

Methods inherited from XPath::XPathNodeSet

#**, #at, #count, def_comparison_operator, #each, #first, #funcall, #predicate, #step, #to_f, #to_ruby, #to_str, #true?

Methods included from XPath::XPathObject

#**, #<, #<=, #==, #>, #>=, #at, #funcall, #predicate, #to_boolean, #to_f, #to_number, #to_predicate, #to_ruby, #to_str, #to_string, #true?

Constructor Details

#initialize(context) ⇒ LocationStep

Returns a new instance of LocationStep.



2713
2714
2715
2716
2717
# File 'lib/xml/xpath.rb', line 2713

def initialize(context)
  @context = context
  @visitor = context.visitor
  @nodes = []
end

Instance Method Details

#reuse(node) ⇒ Object



2723
2724
2725
2726
# File 'lib/xml/xpath.rb', line 2723

def reuse(node)
  @node = node
  @nodes.clear
end

#selectObject



2728
2729
2730
2731
2732
2733
2734
# File 'lib/xml/xpath.rb', line 2728

def select
  @iterator.each(@node, @visitor) { |i|
    node = i.node
    @nodes.push node if yield(i)
  }
  self
end

#select_allObject



2736
2737
2738
2739
# File 'lib/xml/xpath.rb', line 2736

def select_all
  @iterator.each(@node, @visitor) { |i| @nodes.push i.node }
  self
end

#set_iterator(iterator) ⇒ Object



2719
2720
2721
# File 'lib/xml/xpath.rb', line 2719

def set_iterator(iterator)
  @iterator = iterator
end