lib/apportion/setup.rb
# Determines initial portions for recipients according to optional constraints
#
# @param keys [Hash] correspond to recipients
# @param options [Hash]
# @param options [Hash] :prior_portions from a previous apportionment
# @option options [Integer] :required_minimum smallest portion for each recipient
# @return [Hash] portions
# @example
#   initial_portions({a: 41, b: 32, c: 27}, required_minimum: 2)
#   # => {a: 2, b: 2, c: 2}
Determines initial portions for recipients according to optional constraints
Determines initial portions for recipients according to optional constraints
def initial_portions(keys, options)
      portions = Hash.new
      int = options[:required_minimum] || 0
      keys.each { |k| portions[k] = int }
      hash = options[:prior_portions]
      return portions unless hash
      prior_portions_included(portions, hash)
    end
def initial_portions ( keys , options ) portions = Hash . new int = options [ :required_minimum ] || 0 keys . each { | k | portions [ k ] = int } hash = options [ :prior_portions ] return portions unless hash prior_portions_included ( portions , hash ) end
Determines initial portions for recipients according to optional constraints
Determines initial portions for recipients according to optional constraints
None
Hash
keys
correspond to recipients
correspond to recipients
options
:required_minimum smallest portion for each recipient
: required_minimum smallest portion for each recipient
None
example
None