Module: Enumerable
- Defined in:
- lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb
Instance Method Summary collapse
-
#bool_array_combs ⇒ Array
Produces a array with values’s all combinations.
-
#bool_hash_combs ⇒ Hash
Produces a hash with values’s all combinations.
Instance Method Details
#bool_array_combs ⇒ Array
Produces a array with values’s all combinations.
Example:
%i[a b].boolean_combinations
=> [[], [:a], [:b], [:a, :b]]
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_combs ⇒ Hash
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}]
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 |