class Prism::Node

This represents a node in the tree. It is the parent class of all of the various node types.

Attributes

location[R]

A Location instance that represents the location of this node in the source.

Public Instance Methods

pretty_print(q) click to toggle source

Similar to inspect, but respects the current level of indentation given by the pretty print object.

# File lib/prism/node.rb, line 35
def pretty_print(q)
  q.seplist(inspect.chomp.each_line, -> { q.breakable }) do |line|
    q.text(line.chomp)
  end
  q.current_group.break
end
slice() click to toggle source

Slice the location of the node from the source.

# File lib/prism/node.rb, line 29
def slice
  location.slice
end
to_dot() click to toggle source

Convert this node into a graphviz dot graph string.

# File lib/prism/node.rb, line 43
def to_dot
  DotVisitor.new.tap { |visitor| accept(visitor) }.to_dot
end