Sha256: e797d60e700703c04926f1c168852b6a952076d963e554e814fe387d0e6e6ef1
Contents?: true
Size: 576 Bytes
Versions: 1
Compression:
Stored size: 576 Bytes
Contents
module Dmatrix class Matrix def initialize(input) @input = input end 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 private attr_reader :input Combination = Struct.new(:aspects) Aspect = Struct.new(:type, :name, :value) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dmatrix-0.1.0 | lib/dmatrix/matrix.rb |