Class: REXML::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/html/rexml-nodepath.rb

Instance Method Summary collapse

Instance Method Details

#child_indexObject



24
25
26
27
28
29
30
31
# File 'lib/html/rexml-nodepath.rb', line 24

def child_index
  return "" unless parent
  siblings = parent.to_a.select do |node| 
    node.kind_of? Element and node.expanded_name == self.expanded_name
  end
  return "" if siblings.size < 2
  "[" + (siblings.index(self)+1).to_s + "]"
end

#full_pathObject



33
34
35
# File 'lib/html/rexml-nodepath.rb', line 33

def full_path
  parent_path + '/' + expanded_name + child_index
end