Class: Mutant::Expression Private
- Inherits:
-
Object
- Object
- Mutant::Expression
- Defined in:
- lib/mutant/expression.rb,
lib/mutant/expression/method.rb,
lib/mutant/expression/parser.rb,
lib/mutant/expression/source.rb,
lib/mutant/expression/methods.rb,
lib/mutant/expression/namespace.rb,
lib/mutant/expression/descendants.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 match expression
Direct Known Subclasses
Defined Under Namespace
Classes: Descendants, Method, Methods, Namespace, Parser, Source
Constant Summary collapse
- SCOPE_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.
/(?<scope_name>#{fragment}(?:#{SCOPE_OPERATOR}#{fragment})*)/
- SCOPE_SYMBOL_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.
'(?<scope_symbol>[.#])'
Class Method Summary collapse
- .new ⇒ Object private
-
.try_parse(input) ⇒ Expression?
private
Try to parse input into expression of receiver class.
Instance Method Summary collapse
-
#match_length(other) ⇒ Integer
private
Match length with other expression.
-
#prefix?(other) ⇒ Boolean
private
Test if expression is prefix.
Class Method Details
.new ⇒ 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.
13 14 15 |
# File 'lib/mutant/expression.rb', line 13 def self.new(*) super.freeze end |
.try_parse(input) ⇒ Expression?
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.
Try to parse input into expression of receiver class
48 49 50 51 |
# File 'lib/mutant/expression.rb', line 48 def self.try_parse(input) match = self::REGEXP.match(input) from_match(match) if match end |
Instance Method Details
#match_length(other) ⇒ 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.
Match length with other expression
22 23 24 25 26 27 28 |
# File 'lib/mutant/expression.rb', line 22 def match_length(other) if syntax.eql?(other.syntax) syntax.length else 0 end end |
#prefix?(other) ⇒ Boolean
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.
Test if expression is prefix
35 36 37 |
# File 'lib/mutant/expression.rb', line 35 def prefix?(other) !match_length(other).zero? end |