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

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

Overview

Recursive namespace expression

Constant Summary

Constants inherited from Mutant::Expression

METHOD_NAME_PATTERN, REGISTRY, SCOPE_NAME_PATTERN, SCOPE_PATTERN

Instance Attribute Summary

Attributes inherited from Mutant::Expression

#syntax

Instance Method Summary collapse

Methods inherited from Mutant::Expression

parse, #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
25
# File 'lib/mutant/expression/namespace.rb', line 17

def initialize(*)
  super
  namespace_src = Regexp.escape(namespace)
  @recursion_pattern = Regexp.union(
    /\A#{namespace_src}\z/,
    /\A#{namespace_src}::/,
    /\A#{namespace_src}[.#]/
  )
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.

Return length of match

Parameters:

Returns:

  • (Fixnum)


47
48
49
50
51
52
53
# File 'lib/mutant/expression/namespace.rb', line 47

def match_length(expression)
  if @recursion_pattern =~ expression.syntax
    namespace.length
  else
    0
  end
end

#matcher(cache) ⇒ Matcher

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 matcher

Parameters:

Returns:



35
36
37
# File 'lib/mutant/expression/namespace.rb', line 35

def matcher(cache)
  Matcher::Namespace.new(cache, self)
end