class Mutest::Expression

Abstract base class for match expression

Constants

SCOPE_NAME_PATTERN
SCOPE_SYMBOL_PATTERN

Public Class Methods

try_parse(input) click to toggle source

Try to parse input into expression of receiver class

@param [String] input

@return [Expression]

when successful

@return [nil]

otherwise
# File lib/mutest/expression.rb, line 49
def self.try_parse(input)
  match = self::REGEXP.match(input)
  return unless match

  names = anima.attribute_names
  new(Hash[names.zip(names.map(&match.public_method(:[])))])
end

Public Instance Methods

match_length(other) click to toggle source

Match length with other expression

@param [Expression] other

@return [Integer]

# File lib/mutest/expression.rb, line 23
def match_length(other)
  if eql?(other)
    syntax.length
  else
    0
  end
end
prefix?(other) click to toggle source

Test if expression is prefix

@param [Expression] other

@return [Boolean]

# File lib/mutest/expression.rb, line 36
def prefix?(other)
  !match_length(other).zero?
end