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

INSPECT_FORMAT, METHOD_NAME_PATTERN, REGISTRY, SCOPE_NAME_PATTERN, SCOPE_PATTERN

Instance Attribute Summary

Attributes inherited from Mutant::Expression

#inspect, #syntax

Instance Method Summary collapse

Methods inherited from Mutant::Expression

#_dump, _load, 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


29
30
31
32
33
34
35
36
# File 'lib/mutant/expression/namespace.rb', line 29

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

58
59
60
61
62
63
64
# File 'lib/mutant/expression/namespace.rb', line 58

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

#matcher(env) ⇒ 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:


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

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