method
evaluate_predicate
v2_6_3 -
Show latest stable
-
0 notes -
Class: REXML::XPathParser
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3 (0)
- What's this?
evaluate_predicate(expression, nodesets)
private
Hide source
# File lib/rexml/xpath_parser.rb, line 581 def evaluate_predicate(expression, nodesets) # enter(:predicate, expression, nodesets) new_nodesets = nodesets.collect do |nodeset| new_nodeset = [] subcontext = { :size => nodeset.size } nodeset.each_with_index do |node, index| if node.is_a?(XPathNode) subcontext[:node] = node.raw_node subcontext[:index] = node.position else subcontext[:node] = node subcontext[:index] = index + 1 end result = expr(expression.dclone, [node], subcontext) # trace(:predicate_evaluate, expression, node, subcontext, result) result = result[0] if result.kind_of? Array and result.length == 1 if result.kind_of? Numeric if result == node.position new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1) end elsif result.instance_of? Array if result.size > 0 and result.inject(false) {|k,s| s or k} if result.size > 0 new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1) end end else if result new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1) end end end new_nodeset end new_nodesets # ensure # leave(:predicate, new_nodesets) end