class Prism::Node
various node types.
This represents a node in the tree. It is the parent class of all of the
def accept(visitor)
def accept(visitor) raise NoMethodError, "undefined method `accept' for #{inspect}" end
def child_nodes
Returns an array of child nodes, including `nil`s in the place of optional
def child_nodes raise NoMethodError, "undefined method `#{__method__}' for #{inspect}" end
def comment_targets
Returns an array of child nodes and locations that could potentially have
def comment_targets raise NoMethodError, "undefined method `comment_targets' for #{inspect}" end
def compact_child_nodes
Returns an array of child nodes, excluding any `nil`s in the place of
def compact_child_nodes raise NoMethodError, "undefined method `compact_child_nodes' for #{inspect}" end
def newline? # :nodoc:
def newline? # :nodoc: @newline ? true : false end
def pretty_print(q)
Similar to inspect, but respects the current level of indentation given by
def pretty_print(q) q.seplist(inspect.chomp.each_line, -> { q.breakable }) do |line| q.text(line.chomp) end q.current_group.break end
def set_newline_flag(newline_marked) # :nodoc:
def set_newline_flag(newline_marked) # :nodoc: line = location.start_line unless newline_marked[line] newline_marked[line] = true @newline = true end end
def slice
def slice location.slice end
def to_dot
def to_dot DotVisitor.new.tap { |visitor| accept(visitor) }.to_dot end
def type
Returns a symbol symbolizing the type of node that this represents. This
def type raise NoMethodError, "undefined method `type' for #{inspect}" end