Class: Mutant::Expression::Method Private

Inherits:
Mutant::Expression show all
Extended by:
AST::Sexp
Defined in:
lib/mutant/expression/method.rb

Overview

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

Explicit method expression

Constant Summary collapse

MATCHERS =

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

IceNine.deep_freeze(
  '.' => [Matcher::Methods::Singleton, Matcher::Methods::Metaclass],
  '#' => [Matcher::Methods::Instance]
)
METHOD_NAME_PATTERN =

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

/(?<method_name>.+)/.freeze
REGEXP =

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

/\A#{SCOPE_NAME_PATTERN}#{SCOPE_SYMBOL_PATTERN}#{METHOD_NAME_PATTERN}\z/.freeze

Constants inherited from Mutant::Expression

SCOPE_NAME_PATTERN, SCOPE_SYMBOL_PATTERN

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mutant::Expression

#match_length, #prefix?

Class Method Details

.try_parse(input) ⇒ Object

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.



49
50
51
52
53
# File 'lib/mutant/expression/method.rb', line 49

def self.try_parse(input)
  match = REGEXP.match(input) or return

  from_match(match) if valid_method_name?(match[:method_name])
end

Instance Method Details

#matcherMatcher

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

Returns:



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

def matcher
  matcher_candidates = MATCHERS.fetch(scope_symbol)
    .map { |submatcher| submatcher.new(scope) }

  methods_matcher = Matcher::Chain.new(matcher_candidates)

  Matcher::Filter.new(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)


32
33
34
# File 'lib/mutant/expression/method.rb', line 32

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