class method
RubyVM::AbstractSyntaxTree.of
(::Proc | ::Method | ::UnboundMethod body, ?keep_script_lines: bool, ?error_tolerant: bool, ?keep_tokens: bool) -> ::RubyVM::AbstractSyntaxTree::Node?
RubyVM::AbstractSyntaxTree.of(proc, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) → RubyVM::AbstractSyntaxTree::Node
RubyVM::AbstractSyntaxTree.of(method, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) → RubyVM::AbstractSyntaxTree::Node
ast.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/ast.rb, line 95
def self.of body, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false
Primitive.ast_s_of body, keep_script_lines, error_tolerant, keep_tokens
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>
See ::parse for explanation of keyword argument meaning and usage.
See also
.node_id_for_backtrace_location
.parse
.parse_file
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0