RubyVM::AbstractSyntaxTree::Node instances are created by parse methods in RubyVM::AbstractSyntaxTree.

This class is MRI specific.

Instance Methods

Returns AST nodes under this one. Each kind of node has different children, depending on what kind of node it is.

The returned array may contain other nodes or nil.

The column number in the source code where this AST’s text began.

The line number in the source code where this AST’s text began.

Returns debugging information about this node as a string.

The column number in the source code where this AST’s text ended.

The line number in the source code where this AST’s text ended.

Returns an internal node_id number. Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed.

No documentation available
No documentation available

Returns the original source code as an array of lines.

Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed.

Returns the code fragment that corresponds to this AST.

Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed.

Also note that this API may return an incomplete code fragment that does not parse; for example, a here document following an expression may be dropped.

Returns the type of this node as a symbol.

root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
root.type # => :SCOPE
lasgn = root.children[2]
lasgn.type # => :LASGN
call = lasgn.children[1]
call.type # => :OPCALL