Class: Mutant::Expression::Namespace::Recursive

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

Overview

Recursive namespace expression

Constant Summary collapse

REGEXP =
/\A#{SCOPE_NAME_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

Constructor Details

#initializeundefined

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.

Initialize object



17
18
19
20
21
22
23
24
# File 'lib/mutant/expression/namespace.rb', line 17

def initialize(*)
  super
  @recursion_pattern = Regexp.union(
    /\A#{scope_name}\z/,
    /\A#{scope_name}::/,
    /\A#{scope_name}[.#]/
  )
end

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)


52
53
54
55
56
57
58
# File 'lib/mutant/expression/namespace.rb', line 52

def match_length(expression)
  if @recursion_pattern =~ expression.syntax
    scope_name.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.

Matcher for expression

Returns:



41
42
43
# File 'lib/mutant/expression/namespace.rb', line 41

def matcher
  Matcher::Namespace.new(self)
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 for expression

Returns:

  • (String)


31
32
33
# File 'lib/mutant/expression/namespace.rb', line 31

def syntax
  "#{scope_name}*"
end