Sha256: f631932019a78419976c4f8270239e30fb159f48a05c70338e58b4223ed1ce42

Contents?: true

Size: 1.48 KB

Versions: 19

Compression:

Stored size: 1.48 KB

Contents

module RR
class ScenarioMatches
  attr_reader :matching_scenarios,
              :exact_terminal_scenarios_to_attempt,
              :exact_non_terminal_scenarios_to_attempt,
              :wildcard_terminal_scenarios_to_attempt,
              :wildcard_non_terminal_scenarios_to_attempt
  def initialize(scenarios)
    @scenarios = scenarios
    @matching_scenarios = []
    @exact_terminal_scenarios_to_attempt = []
    @exact_non_terminal_scenarios_to_attempt = []
    @wildcard_terminal_scenarios_to_attempt = []
    @wildcard_non_terminal_scenarios_to_attempt = []
  end

  def find_all_matches!(args)
    @scenarios.each do |scenario|
      if scenario.exact_match?(*args)
        matching_scenarios << scenario
        if scenario.attempt?
          exact_scenario_is_terminal_or_non_terminal scenario
        end
      elsif scenario.wildcard_match?(*args)
        matching_scenarios << scenario
        if scenario.attempt?
          wildcard_scenario_is_terminal_or_non_terminal scenario
        end
      end
    end
    self
  end

  protected
  def exact_scenario_is_terminal_or_non_terminal(scenario)
    if scenario.terminal?
      exact_terminal_scenarios_to_attempt << scenario
    else
      exact_non_terminal_scenarios_to_attempt << scenario
    end
  end

  def wildcard_scenario_is_terminal_or_non_terminal(scenario)
    if scenario.terminal?
      wildcard_terminal_scenarios_to_attempt << scenario
    else
      wildcard_non_terminal_scenarios_to_attempt << scenario
    end
  end
end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rr-0.1.15 lib/rr/scenario_matches.rb
rr-0.1.14 lib/rr/scenario_matches.rb
rr-0.2.2 lib/rr/scenario_matches.rb
rr-0.2.5 lib/rr/scenario_matches.rb
rr-0.2.1 lib/rr/scenario_matches.rb
rr-0.3.11 lib/rr/scenario_matches.rb
rr-0.3.1 lib/rr/scenario_matches.rb
rr-0.3.3 lib/rr/scenario_matches.rb
rr-0.3.2 lib/rr/scenario_matches.rb
rr-0.2.3 lib/rr/scenario_matches.rb
rr-0.2.4 lib/rr/scenario_matches.rb
rr-0.3.0 lib/rr/scenario_matches.rb
rr-0.3.10 lib/rr/scenario_matches.rb
rr-0.3.4 lib/rr/scenario_matches.rb
rr-0.3.9 lib/rr/scenario_matches.rb
rr-0.3.5 lib/rr/scenario_matches.rb
rr-0.3.6 lib/rr/scenario_matches.rb
rr-0.3.8 lib/rr/scenario_matches.rb
rr-0.3.7 lib/rr/scenario_matches.rb