Class: Mutant::Expression::Method

Inherits:
Mutant::Expression show all
Defined in:
lib/mutant/expression/method.rb

Overview

Explicit method expression

Constant Summary collapse

MATCHERS =
IceNine.deep_freeze(
  '.' => Matcher::Methods::Singleton,
  '#' => Matcher::Methods::Instance
)
METHOD_NAME_PATTERN =
Regexp.union(
  /(?<method_name>[A-Za-z_][A-Za-z\d_]*[!?=]?)/,
  *AST::Types::OPERATOR_METHODS.map(&:to_s)
).freeze
REGEXP =
/\A#{SCOPE_NAME_PATTERN}#{SCOPE_SYMBOL_PATTERN}#{METHOD_NAME_PATTERN}\z/.freeze

Constants inherited from Mutant::Expression

SCOPE_NAME_PATTERN, SCOPE_SYMBOL_PATTERN

Instance Method Summary collapse

Methods inherited from Mutant::Expression

#match_length, #prefix?, try_parse

Instance Method Details

#matcher(env) ⇒ Matcher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Matcher for expression

Parameters:

Returns:



40
41
42
43
44
# File 'lib/mutant/expression/method.rb', line 40

def matcher(env)
  methods_matcher = MATCHERS.fetch(scope_symbol).new(env, scope)

  Matcher::Filter.build(methods_matcher) { |subject| subject.expression.eql?(self) }
end

#syntaxString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Syntax of expression

Returns:

  • (String)


28
29
30
# File 'lib/mutant/expression/method.rb', line 28

def syntax
  [scope_name, scope_symbol, method_name].join
end