Module REXML::Node
In: lib/rexml/node.rb

Represents a node in the tree. Nodes are never encountered except as superclasses of other objects. Nodes have siblings.

Methods

Public Instance methods

Visit all subnodes of self recursively

[Source]

    # File lib/rexml/node.rb, line 42
42:                 def each_recursive(&block) # :yields: node
43:                         self.elements.each {|node|
44:                                 block.call(node)
45:                                 node.each_recursive(&block)
46:                         }
47:                 end

Find (and return) first subnode (recursively) for which the block evaluates to true. Returns nil if none was found.

[Source]

    # File lib/rexml/node.rb, line 51
51:                 def find_first_recursive(&block) # :yields: node
52:       each_recursive {|node|
53:         return node if block.call(node)
54:       }
55:       return nil
56:     end

[Source]

    # File lib/rexml/node.rb, line 27
27:                 def indent to, ind
28:                         if @parent and @parent.context and not @parent.context[:indentstyle].nil? then
29:                                 indentstyle = @parent.context[:indentstyle]
30:                         else
31:                                 indentstyle = '  '
32:                         end
33:                         to << indentstyle*ind unless ind<1
34:                 end

Returns the index that self has in its parent‘s elements array, so that the following equation holds true:

  node == node.parent.elements[node.index_in_parent]

[Source]

    # File lib/rexml/node.rb, line 62
62:     def index_in_parent
63:       parent.index(self)+1
64:     end

@return the next sibling (nil if unset)

[Source]

    # File lib/rexml/node.rb, line 8
 8:                 def next_sibling_node
 9:                         return nil if @parent.nil?
10:                         @parent[ @parent.index(self) + 1 ]
11:                 end

[Source]

    # File lib/rexml/node.rb, line 36
36:                 def parent?
37:                         false;
38:                 end

@return the previous sibling (nil if unset)

[Source]

    # File lib/rexml/node.rb, line 14
14:                 def previous_sibling_node
15:                         return nil if @parent.nil?
16:                         ind = @parent.index(self)
17:                         return nil if ind == 0
18:                         @parent[ ind - 1 ]
19:                 end

[Source]

    # File lib/rexml/node.rb, line 21
21:                 def to_s indent=-1
22:                         rv = ""
23:                         write rv,indent
24:                         rv
25:                 end

[Validate]