Class: Dmatrix::Matrix
- Inherits:
-
Object
- Object
- Dmatrix::Matrix
- Defined in:
- lib/dmatrix/matrix.rb
Defined Under Namespace
Classes: Aspect, Combination
Instance Method Summary collapse
- #combinations ⇒ Object
-
#initialize(input) ⇒ Matrix
constructor
A new instance of Matrix.
Constructor Details
#initialize(input) ⇒ Matrix
Returns a new instance of Matrix.
3 4 5 |
# File 'lib/dmatrix/matrix.rb', line 3 def initialize(input) @input = input end |
Instance Method Details
#combinations ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/dmatrix/matrix.rb', line 7 def combinations dimensions = [] input.each do |type, dimension_group| dimension_group.each do |(name, values)| dimensions << values.map { |value| Aspect.new(type, name, value) } end end dimensions.first.product(*dimensions.drop(1)).map do |aspects| Combination.new(aspects) end end |