Class: Mutant::Expression
- Inherits:
-
Object
- Object
- Mutant::Expression
- Includes:
- AbstractType, Adamantium
- Defined in:
- lib/mutant/expression.rb,
lib/mutant/expression/method.rb,
lib/mutant/expression/namespace.rb
Overview
Abstract base class for match expression
Defined Under Namespace
Constant Summary collapse
- SCOPE_NAME_PATTERN =
/[A-Za-z][A-Za-z\d_]*/.freeze
- METHOD_NAME_PATTERN =
Regexp.union( /[A-Za-z_][A-Za-z\d_]*[!?=]?/, *OPERATOR_METHODS.map(&:to_s) ).freeze
- SCOPE_PATTERN =
/ (?:#{SCOPE_OPERATOR})?#{SCOPE_NAME_PATTERN} (?:#{SCOPE_OPERATOR}#{SCOPE_NAME_PATTERN})* /x.freeze
- REGISTRY =
{}
Instance Attribute Summary collapse
-
#syntax ⇒ String
readonly
private
Return syntax.
Class Method Summary collapse
-
.parse(pattern) ⇒ Expression?
private
Parse input into expression.
Instance Method Summary collapse
-
#initialize ⇒ Expression
constructor
Initialize expression.
-
#match_length(neddle) ⇒ Fixnum
Return match length for expression.
Constructor Details
#initialize ⇒ Expression
Initialize expression
26 27 28 29 |
# File 'lib/mutant/expression.rb', line 26 def initialize(*) super @syntax = match.to_s 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.
Return syntax
37 38 39 |
# File 'lib/mutant/expression.rb', line 37 def syntax @syntax end |
Class Method Details
.parse(pattern) ⇒ 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.
Parse input into expression
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/mutant/expression.rb', line 76 def self.parse(pattern) expressions = expressions(pattern) case expressions.length when 0 when 1 expressions.first else fail "Ambigous expression: #{pattern.inspect}" end end |
Instance Method Details
#match_length(neddle) ⇒ Fixnum
Return match length for expression
45 46 47 48 49 50 51 |
# File 'lib/mutant/expression.rb', line 45 def match_length(neddle) if eql?(neddle) syntax.length else 0 end end |