Class: RubyNext::Language::Rewriters::ItParam
Constant Summary collapse
- NAME =
"it-param"- SYNTAX_PROBE =
"proc { it.keys }.call({})"- MIN_SUPPORTED_VERSION =
Gem::Version.new("3.4.0")
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Methods inherited from Abstract
ast?, #initialize, text?, transform, unsupported_syntax?, unsupported_version?
Constructor Details
This class inherits a constructor from RubyNext::Language::Rewriters::Base
Instance Method Details
#on_block(node) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby-next/language/rewriters/edge/it_param.rb', line 13 def on_block(node) proc_or_lambda, args, body = *node.children return super unless block_has_it?(body) context.track! self new_body = s(:begin, s(:lvasgn, :it, s(:lvar, :_1)), body) insert_before(body.loc.expression, "it = _1;") process( node.updated(:numblock, [ proc_or_lambda, args, new_body ]) ) end |