Sha256: 0149c3db974a3efe6bfddacc9fd6e92c68a57ac31201944de5605c98e22cc6a7

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

module RR
  class DoubleMatches
    attr_reader :matching_doubles,
                :exact_terminal_doubles_to_attempt,
                :exact_non_terminal_doubles_to_attempt,
                :wildcard_terminal_doubles_to_attempt,
                :wildcard_non_terminal_doubles_to_attempt

    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

    def find_all_matches(args, kwargs)
      kwargs ||= {}
      @doubles.each do |double|
        if double.exact_match?(args, kwargs)
          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, kwargs)
          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
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rr-3.1.1 lib/rr/double_matches.rb
rr-3.1.0 lib/rr/double_matches.rb
rr-3.0.9 lib/rr/double_matches.rb
rr-3.0.8 lib/rr/double_matches.rb
rr-3.0.7 lib/rr/double_matches.rb
rr-3.0.6 lib/rr/double_matches.rb
rr-3.0.5 lib/rr/double_matches.rb
rr-3.0.4 lib/rr/double_matches.rb
rr-3.0.3 lib/rr/double_matches.rb
rr-3.0.2 lib/rr/double_matches.rb
rr-3.0.1 lib/rr/double_matches.rb
rr-3.0.0 lib/rr/double_matches.rb