Class: Pairwise::PairCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/pairwise/pair_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(input_parameter_values, input_value_lists, input_parameter_index) ⇒ PairCollection

Returns a new instance of PairCollection.



4
5
6
7
8
# File 'lib/pairwise/pair_collection.rb', line 4

def initialize(input_parameter_values, input_value_lists, input_parameter_index)
  pairs = generate_pairs_between(input_parameter_values, input_value_lists, input_parameter_index)
  @combination_history = []
  super(pairs)
end

Instance Method Details

#input_combination_that_covers_most_pairs(input_combination, input_values_for_growth) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pairwise/pair_collection.rb', line 14

def input_combination_that_covers_most_pairs(input_combination, input_values_for_growth)
  candidates = input_values_for_growth.map{|value| input_combination + [value]}
  max_combination = candidates.max {|combination_1, combination_2| pairs_covered_count(combination_1) <=> pairs_covered_count(combination_2)}
  possible_max_combinations = candidates.select{|combination| pairs_covered_count(max_combination) == pairs_covered_count(combination)}

  winner = if possible_max_combinations.size > 1 && !@combination_history.empty?
    find_most_different_combination(possible_max_combinations)
  else
    possible_max_combinations[0]
  end
  @combination_history << winner
  winner
end

#remove_pairs_covered_by!(extended_input_list) ⇒ Object



10
11
12
# File 'lib/pairwise/pair_collection.rb', line 10

def remove_pairs_covered_by!(extended_input_list)
  self.reject!{|pair| pair.covered_by?(extended_input_list)}
end

#to_aObject



28
29
30
# File 'lib/pairwise/pair_collection.rb', line 28

def to_a
  self.map{|list| list.to_a}
end