Class: RubyNext::Language::Rewriters::NumberedParams
Constant Summary collapse
- NAME =
"numbered-params"
- SYNTAX_PROBE =
"proc { _1 }.call(1)"
- MIN_SUPPORTED_VERSION =
Gem::Version.new("2.7.0")
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Methods inherited from Abstract
ast?, #initialize, text?, unsupported_syntax?, unsupported_version?
Constructor Details
This class inherits a constructor from RubyNext::Language::Rewriters::Base
Instance Method Details
#on_numblock(node) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruby-next/language/rewriters/2.7/numbered_params.rb', line 13 def on_numblock(node) context.track! self proc_or_lambda, num, body = *node.children if proc_or_lambda.type == :lambda insert_before(node.loc.begin, "(#{proc_args_str(num)})") else insert_after(node.loc.begin, " |#{proc_args_str(num)}|") end node.updated( :block, [ proc_or_lambda, proc_args(num), body ] ) end |