class Object

Public Instance Methods

prnAttrs(node) click to toggle source
# File examples/Visualise/xpath_visual.rb, line 10
def prnAttrs(node)
  str = node.attributes.collect{ |a| rememberPath(a.path,a.name + '="' + a.to_s + '"') }.join(" ")
  str == "" ? "" :  " " + str
end
prnTree(node,depth,mixed) click to toggle source
# File examples/Visualise/xpath_visual.rb, line 15
def prnTree(node,depth,mixed)
  print " " * depth unless mixed
  print "<" + rememberPath(node.path,node.name.to_s) + prnAttrs(node) + ">"
  print "\n" if !node.mixed? && !mixed && node.children?
  node.children.each { |n|
    case n
      when XML::Smart::Dom::Element: prnTree(n,depth+2,node.mixed? | mixed)
      when XML::Smart::Dom::Text: print rememberPath(n.path,n.text)
    end  
  }
  print " " * depth if !node.mixed? && !mixed && node.children?
  print "</" + rememberPath(node.path,node.name.to_s) + ">" 
  print "\n" unless mixed
end
rememberPath(path,output) click to toggle source
# File examples/Visualise/xpath_visual.rb, line 6
def rememberPath(path,output)
  @remember.include?(path) ? red + output + clear : output
end