Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Prism::Translation::RubyParser::Compiler#visit_def_node
visit_def_node(node)
lib/prism/translation/ruby_parser.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/prism/translation/ruby_parser.rb, line 518
def visit_def_node(node)
name = node.name_loc.slice.to_sym
result =
if node.receiver.nil?
s(node, :defn, name)
else
s(node, :defs, visit(node.receiver), name)
end
result.line(node.name_loc.start_line)
if node.parameters.nil?
result << s(node, :args).line(node.name_loc.start_line)
else
result << visit(node.parameters)
end
if node.body.nil?
result << s(node, :nil)
elsif node.body.is_a?(StatementsNode)
compiler = copy_compiler(in_def: true)
result.concat(node.body.body.map { |child| child.accept(compiler) })
else
result << node.body.accept(copy_compiler(in_def: true))
end
end
def foo; end ^^^^^^^^^^^^
def self.foo; end ^^^^^^^^^^^^^^^^^