Class: RubyNext::Language::Rewriters::MethodReference

Inherits:
Text
  • Object
show all
Defined in:
lib/ruby-next/language/rewriters/proposed/method_reference.rb

Constant Summary collapse

NAME =
"method-reference"
SYNTAX_PROBE =
"Language.:transform"
MIN_SUPPORTED_VERSION =
Gem::Version.new(RubyNext::NEXT_VERSION)

Instance Method Summary collapse

Methods inherited from Text

paco_parser, parser, #rewrite, text?

Methods inherited from Abstract

ast?, #initialize, text?, unsupported_syntax?, unsupported_version?

Constructor Details

This class inherits a constructor from RubyNext::Language::Rewriters::Abstract

Instance Method Details

#safe_rewrite(source) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/ruby-next/language/rewriters/proposed/method_reference.rb', line 14

def safe_rewrite(source)
  source.gsub(/\.:([\w_]+)/) do |match|
    context.track! self

    ".method(:#{$1})"
  end
end