In Files

  • ast.c
  • ast.rb

Class/Module Index [+]

Quicksearch

RubyVM::AbstractSyntaxTree::Node

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

This class is MRI specific.

Public Instance Methods

children → array click to toggle source

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.

 
               # File ast.rb, line 131
def children
  __builtin_ast_node_children
end
            
first_column → integer click to toggle source

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

 
               # File ast.rb, line 104
def first_column
  __builtin_ast_node_first_column
end
            
first_lineno → integer click to toggle source

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

 
               # File ast.rb, line 96
def first_lineno
  __builtin_ast_node_first_lineno
end
            
inspect → string click to toggle source

Returns debugging information about this node as a string.

 
               # File ast.rb, line 139
def inspect
  __builtin_ast_node_inspect
end
            
last_column → integer click to toggle source

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

 
               # File ast.rb, line 120
def last_column
  __builtin_ast_node_last_column
end
            
last_lineno → integer click to toggle source

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

 
               # File ast.rb, line 112
def last_lineno
  __builtin_ast_node_last_lineno
end
            
type → symbol click to toggle source

Returns the type of this node as a symbol.

root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
root.type # => :SCOPE
call = root.children[2]
call.type # => :OPCALL
 
               # File ast.rb, line 88
def type
  __builtin_ast_node_type
end