Method: MTK::Patterns::Choice#initialize
- Defined in:
- lib/mtk/patterns/choice.rb
#initialize(elements, options = {}) ⇒ Choice
Returns a new instance of Choice.
16 17 18 19 20 |
# File 'lib/mtk/patterns/choice.rb', line 16 def initialize(elements, ={}) super @weights = .fetch :weights, Array.new(@elements.length, 1) @total_weight = @weights.inject(:+).to_f end |