lib/apportion.rb
# Distributes a quantity among recipients by dividing proportionally according to relative
# weights using the 'equal proportions' algorithm
#
# @param weights [Hash] relative integer proportions
# @param size [Integer] quantity to apportion
# @param options [Hash]
# @option options [Hash] :prior_portions from a previous apportionment
# @option options [Integer] :required_minimum smallest portion for each recipient
# @return [Hash] portions
# @example
#   division({a: 41, b: 32, c: 27}, 7)
#   # => {a: 3, b: 2, c: 2}
Distributes a quantity among recipients by dividing proportionally according to relative
weights using the 'equal proportions' algorithm
Distributes a quantity among recipients by dividing proportionally according to relative weights using the ' equal proportions ' algorithm
def division(weights, size, options = {})
    portions = Setup.initial_portions(weights.keys, options)
    sum_portions = Util.hash_values_sum(portions)
    Setup.validate(size, sum_portions)
    next_step(weights, portions, sum_portions, size)
  end
def division ( weights , size , options = { } ) portions = Setup . initial_portions ( weights . keys , options ) sum_portions = Util . hash_values_sum ( portions ) Setup . validate ( size , sum_portions ) next_step ( weights , portions , sum_portions , size ) end
Distributes a quantity among recipients by dividing proportionally according to relative
weights using the 'equal proportions' algorithm
Distributes a quantity among recipients by dividing proportionally according to relative weights using the ' equal proportions ' algorithm
None
Hash
weights
relative integer proportions
relative integer proportions
size
quantity to apportion
quantity to apportion
options
:required_minimum smallest portion for each recipient
: required_minimum smallest portion for each recipient
None
example
None