Module: Apportion
 Defined in:
 lib/apportion.rb,
lib/apportion/util.rb,
lib/apportion/setup.rb,
lib/apportion/version.rb,
lib/apportion/algorithm/equal_proportions.rb
Overview
Top level interface, or API, to distribute a quantity among recipients
Defined Under Namespace
Modules: Algorithm, Setup, Util
Constant Summary collapse
 VERSION =
'0.0.1'
Class Method Summary collapse

.division(weights, size, options = {}) ⇒ Hash
Distributes a quantity among recipients by dividing proportionally according to relative weights using the 'equal proportions' algorithm.
Methods included from Util
file_read_json_to_hash, hash_values_sum, symbolize_keys
Methods included from Setup
Class Method Details
.division(weights, size, options = {}) ⇒ Hash
Distributes a quantity among recipients by dividing proportionally according to relative weights using the 'equal proportions' algorithm
24 25 26 27 28 29 
# File 'lib/apportion.rb', line 24 def division(weights, size, = {}) portions = initial_portions(weights.keys, ) sum_portions = hash_values_sum(portions) validate(size, sum_portions) next_step(weights, portions, sum_portions, size) end 