Class

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

Attributes
Read

A pointer to the source that this node was created from.

Class Methods

Returns a list of the fields that exist for this node class. Fields describe the structure of the node. This kind of reflection is useful for things like recursively visiting each node and field in the tree.

Returns the type of the node as a symbol.

Instance Methods

Accepts a visitor and calls back into the specialized visit function.

Returns an array of child nodes, including ‘nil`s in the place of optional nodes that were not present.

Returns an array of child nodes and locations that could potentially have comments attached to them.

Returns an array of child nodes, excluding any ‘nil`s in the place of optional nodes that were not present.

An alias for child_nodes

The end offset of the node in the source. This method is effectively a delegate method to the location object.

Returns a string representation of the node.

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

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

An alias for source_lines

Slice the location of the node from the source.

Slice the location of the node from the source, starting at the beginning of the line that the location starts on, ending at the end of the line that the location ends on.

Returns all of the lines of the source code associated with this node.

The start offset of the node in the source. This method is effectively a delegate method to the location object.

Convert this node into a graphviz dot graph string.

Returns a list of nodes that are descendants of this node that contain the given line and column. This is useful for locating a node that is selected based on the line and column of the source code.

Important to note is that the column given to this method should be in bytes, as opposed to characters or code units.

Returns a symbol symbolizing the type of node that this represents. This is particularly useful for case statements and array comparisons.