End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
RubyVM::AbstractSyntaxTree.of
RubyVM::AbstractSyntaxTree.of(proc) → RubyVM::AbstractSyntaxTree::Node
RubyVM::AbstractSyntaxTree.of(method) → RubyVM::AbstractSyntaxTree::Node
ast.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/ast.rb, line 66
def self.of body, keep_script_lines: false
Primitive.ast_s_of body, keep_script_lines
end
Returns AST nodes of the given proc or method.
Example
RubyVM::AbstractSyntaxTree.of(proc {1 + 2}) # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:35-1:42> def hello puts "hello, world" end RubyVM::AbstractSyntaxTree.of(method(:hello)) # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-3:3>