Class: Mutant::Expression::Methods

Inherits:
Mutant::Expression show all
Defined in:
lib/mutant/expression/methods.rb

Overview

Abstract base class for methods expression

Constant Summary collapse

MATCHERS =
IceNine.deep_freeze(
  '.' => Matcher::Methods::Singleton,
  '#' => Matcher::Methods::Instance
)
REGEXP =
/\A#{SCOPE_NAME_PATTERN}#{SCOPE_SYMBOL_PATTERN}\z/.freeze

Constants inherited from Mutant::Expression

SCOPE_NAME_PATTERN, SCOPE_SYMBOL_PATTERN

Instance Method Summary collapse

Methods inherited from Mutant::Expression

#prefix?, try_parse

Instance Method Details

#match_length(expression) ⇒ Fixnum

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

Parameters:

Returns:

  • (Fixnum)


43
44
45
46
47
48
49
# File 'lib/mutant/expression/methods.rb', line 43

def match_length(expression)
  if expression.syntax.start_with?(syntax)
    syntax.length
  else
    0
  end
end

#matcherMatcher::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

Returns:



32
33
34
# File 'lib/mutant/expression/methods.rb', line 32

def matcher
  MATCHERS.fetch(scope_symbol).new(scope)
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)


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

def syntax
  [scope_name, scope_symbol].join
end