Class: Fakes::CombinedArgMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/core/arg_matching/combined_arg_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CombinedArgMatcher

Returns a new instance of CombinedArgMatcher.



5
6
7
# File 'lib/core/arg_matching/combined_arg_matcher.rb', line 5

def initialize(options = {})
  @all_matchers = options.fetch(:matchers,[])
end

Instance Attribute Details

#all_matchersObject (readonly)

Returns the value of attribute all_matchers.



3
4
5
# File 'lib/core/arg_matching/combined_arg_matcher.rb', line 3

def all_matchers
  @all_matchers
end

Instance Method Details

#add(matcher) ⇒ Object



18
19
20
# File 'lib/core/arg_matching/combined_arg_matcher.rb', line 18

def add(matcher)
  @all_matchers << matcher
end

#matches?(args) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
# File 'lib/core/arg_matching/combined_arg_matcher.rb', line 9

def matches?(args)
  matches = true
  for index in 0..@all_matchers.count - 1
    matches &= @all_matchers[index].matches?(args[index])
    return false unless matches
  end
  matches
end