Class: Mutant::Expression::Method Private
- Inherits:
-
Mutant::Expression
- Object
- Mutant::Expression
- Mutant::Expression::Method
- 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.
{ '.' => [Matcher::Methods::Singleton, Matcher::Methods::Metaclass].freeze, '#' => [Matcher::Methods::Instance].freeze }.freeze
- 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>.+)/
- 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/
Constants inherited from Mutant::Expression
SCOPE_NAME_PATTERN, SCOPE_SYMBOL_PATTERN
Instance Attribute Summary collapse
-
#syntax ⇒ String
readonly
private
Syntax of expression.
Class Method Summary collapse
- .try_parse(input) ⇒ Object private
Instance Method Summary collapse
-
#initialize ⇒ Method
constructor
private
A new instance of Method.
-
#matcher(env:) ⇒ Matcher
private
Matcher for expression.
Methods inherited from Mutant::Expression
Constructor Details
#initialize ⇒ Method
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.
Returns a new instance of Method.
29 30 31 32 |
# File 'lib/mutant/expression/method.rb', line 29 def initialize(*) super @syntax = [scope_name, scope_symbol, method_name].join.freeze end |
Instance Attribute Details
#syntax ⇒ String (readonly)
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
37 38 39 |
# File 'lib/mutant/expression/method.rb', line 37 def syntax @syntax end |
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.
56 57 58 59 60 |
# File 'lib/mutant/expression/method.rb', line 56 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
#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
rubocop:disable Lint/UnusedMethodArgument
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/mutant/expression/method.rb', line 44 def matcher(env:) matcher_candidates = MATCHERS.fetch(scope_symbol) .map { |submatcher| submatcher.new(scope:) } methods_matcher = Matcher::Chain.new(matchers: matcher_candidates) Matcher::Filter.new( matcher: methods_matcher, predicate: ->(subject) { subject.expression.eql?(self) } ) end |