Class: Mutant::Expression Private

Inherits:
Object
  • Object
show all
Includes:
AbstractType
Defined in:
lib/mutant/expression.rb,
lib/mutant/expression/method.rb,
lib/mutant/expression/parser.rb,
lib/mutant/expression/methods.rb,
lib/mutant/expression/namespace.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

Method, Methods, Namespace

Defined Under Namespace

Classes: Method, Methods, Namespace, Parser

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})*)/.freeze
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

Instance Method Summary collapse

Class Method Details

.newObject

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.



15
16
17
# File 'lib/mutant/expression.rb', line 15

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

Parameters:

  • input (String)

Returns:

  • (Expression)

    when successful

  • (nil)

    otherwise



60
61
62
63
# File 'lib/mutant/expression.rb', line 60

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

Parameters:

Returns:

  • (Integer)


34
35
36
37
38
39
40
# File 'lib/mutant/expression.rb', line 34

def match_length(other)
  if syntax.eql?(other.syntax)
    syntax.length
  else
    0
  end
end

#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.

Syntax of expression

Returns:



22
# File 'lib/mutant/expression.rb', line 22

abstract_method :matcher

#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

Parameters:

Returns:

  • (Boolean)


47
48
49
# File 'lib/mutant/expression.rb', line 47

def prefix?(other)
  !match_length(other).zero?
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)


27
# File 'lib/mutant/expression.rb', line 27

abstract_method :syntax