Class: Mutant::Expression::Methods Private
- Inherits:
-
Mutant::Expression
- Object
- Mutant::Expression
- Mutant::Expression::Methods
- Defined in:
- lib/mutant/expression/methods.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.
Abstract base class for methods 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
- 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}\z/
Constants inherited from Mutant::Expression
SCOPE_NAME_PATTERN, SCOPE_SYMBOL_PATTERN
Instance Attribute Summary collapse
-
#syntax ⇒ String
readonly
private
Syntax of expression.
Instance Method Summary collapse
-
#initialize ⇒ Methods
constructor
private
A new instance of Methods.
-
#match_length(expression) ⇒ Integer
private
Length of match with other expression.
-
#matcher(env:) ⇒ Matcher::Method
private
Matcher on expression.
Methods inherited from Mutant::Expression
Constructor Details
#initialize ⇒ Methods
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 Methods.
24 25 26 27 |
# File 'lib/mutant/expression/methods.rb', line 24 def initialize(*) super @syntax = [scope_name, scope_symbol].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
32 33 34 |
# File 'lib/mutant/expression/methods.rb', line 32 def syntax @syntax end |
Instance Method Details
#match_length(expression) ⇒ Integer
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.
Length of match with other expression
51 52 53 54 55 56 57 |
# File 'lib/mutant/expression/methods.rb', line 51 def match_length(expression) if expression.syntax.start_with?(syntax) syntax.length else 0 end end |
#matcher(env:) ⇒ Matcher::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.
Matcher on expression
rubocop:disable Lint/UnusedMethodArgument
39 40 41 42 43 44 |
# File 'lib/mutant/expression/methods.rb', line 39 def matcher(env:) matcher_candidates = MATCHERS.fetch(scope_symbol) .map { |submatcher| submatcher.new(scope:) } Matcher::Chain.new(matchers: matcher_candidates) end |