Module: Enumerable

Defined in:
lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb

Instance Method Summary collapse

Instance Method Details

#bool_array_combsArray

Produces a array with values’s all combinations.

Example:

%i[a b].boolean_combinations
=> [[], [:a], [:b], [:a, :b]]

Returns:

  • (Array)


11
12
13
# File 'lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb', line 11

def bool_array_combs
  bool_combs([], method(:bool_array_combs_new_comb))
end

#bool_hash_combsHash

Produces a hash with values’s all combinations.

Example:

%i[a b].boolean_combinations
=> [{a: false, b: false}, {a: false, b: true}, {a: true, b: false}, {a: true, b: true}]

Returns:



22
23
24
# File 'lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb', line 22

def bool_hash_combs
  bool_combs({}, method(:bool_hash_combs_new_comb))
end