1
require "rexml/parseexception"
4
# Represents a node in the tree. Nodes are never encountered except as
5
# superclasses of other objects. Nodes have siblings.
7
# @return the next sibling (nil if unset)
9
return nil if @parent.nil?
10
@parent[ @parent.index(self) + 1 ]
13
# @return the previous sibling (nil if unset)
14
def previous_sibling_node
15
return nil if @parent.nil?
16
ind = @parent.index(self)
17
return nil if ind == 0
28
if @parent and @parent.context and not @parent.context[:indentstyle].nil? then
29
indentstyle = @parent.context[:indentstyle]
33
to << indentstyle*ind unless ind<1
41
# Visit all subnodes of +self+ recursively
42
def each_recursive(&block) # :yields: node
43
self.elements.each {|node|
45
node.each_recursive(&block)
49
# Find (and return) first subnode (recursively) for which the block
50
# evaluates to true. Returns +nil+ if none was found.
51
def find_first_recursive(&block) # :yields: node
52
each_recursive {|node|
53
return node if block.call(node)
58
# Returns the position that +self+ holds in its parent's array, indexed