instance method
Prism::Translation::Ripper#visit_number_node
visit_number_node(node) { |slice| ... }
lib/prism/translation/ripper.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/translation/ripper.rb, line 3345
def visit_number_node(node)
slice = node.slice
location = node.location
if slice[0] == "-"
bounds(location.copy(start_offset: location.start_offset + 1))
value = yield slice[1..-1]
bounds(node.location)
on_unary(:-@, value)
else
bounds(location)
yield slice
end
end
Visit a node that represents a number. We need to explicitly handle the unary - operator.