Class: RR::DoubleMatches

Inherits:
Object
  • Object
show all
Defined in:
lib/rr/double_matches.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doubles) ⇒ DoubleMatches

:nodoc:



8
9
10
11
12
13
14
15
# File 'lib/rr/double_matches.rb', line 8

def initialize(doubles) #:nodoc:
  @doubles = doubles
  @matching_doubles = []
  @exact_terminal_doubles_to_attempt = []
  @exact_non_terminal_doubles_to_attempt = []
  @wildcard_terminal_doubles_to_attempt = []
  @wildcard_non_terminal_doubles_to_attempt = []
end

Instance Attribute Details

#exact_non_terminal_doubles_to_attemptObject (readonly)

Returns the value of attribute exact_non_terminal_doubles_to_attempt



3
4
5
# File 'lib/rr/double_matches.rb', line 3

def exact_non_terminal_doubles_to_attempt
  @exact_non_terminal_doubles_to_attempt
end

#exact_terminal_doubles_to_attemptObject (readonly)

Returns the value of attribute exact_terminal_doubles_to_attempt



3
4
5
# File 'lib/rr/double_matches.rb', line 3

def exact_terminal_doubles_to_attempt
  @exact_terminal_doubles_to_attempt
end

#matching_doublesObject (readonly)

Returns the value of attribute matching_doubles



3
4
5
# File 'lib/rr/double_matches.rb', line 3

def matching_doubles
  @matching_doubles
end

#wildcard_non_terminal_doubles_to_attemptObject (readonly)

Returns the value of attribute wildcard_non_terminal_doubles_to_attempt



3
4
5
# File 'lib/rr/double_matches.rb', line 3

def wildcard_non_terminal_doubles_to_attempt
  @wildcard_non_terminal_doubles_to_attempt
end

#wildcard_terminal_doubles_to_attemptObject (readonly)

Returns the value of attribute wildcard_terminal_doubles_to_attempt



3
4
5
# File 'lib/rr/double_matches.rb', line 3

def wildcard_terminal_doubles_to_attempt
  @wildcard_terminal_doubles_to_attempt
end

Instance Method Details

#find_all_matches(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rr/double_matches.rb', line 17

def find_all_matches(args)
  @doubles.each do |double|
    if double.exact_match?(*args)
      matching_doubles << double
      if double.attempt?
        if double.terminal?
          exact_terminal_doubles_to_attempt << double
        else
          exact_non_terminal_doubles_to_attempt << double
        end
      end
    elsif double.wildcard_match?(*args)
      matching_doubles << double
      if double.attempt?
        if double.terminal?
          wildcard_terminal_doubles_to_attempt << double
        else
          wildcard_non_terminal_doubles_to_attempt << double
        end
      end
    end
  end
  self
end