Skip to content

Instantly share code, notes, and snippets.

@eprothro
Created December 20, 2017 19:00
Show Gist options
  • Save eprothro/b08be300aacf40eeb5b7535fb90c68a6 to your computer and use it in GitHub Desktop.
Save eprothro/b08be300aacf40eeb5b7535fb90c68a6 to your computer and use it in GitHub Desktop.
irb
allocation = {
events: 3_131_647.7,
fanout: 1_234_271.5,
default: 17_179_872,
detonation: 705_552.8,
assets: 4_664_397
}

sum = allocation.values.reduce(&:+)

allocation.each do |k, v|
 puts "#{k}: #{((v/sum)*100).round(0)}"
end
=> {:events=>3131647.7, :fanout=>1234271.5, :default=>17179872, :detonation=>705552.8, :assets=>4664397}
=> 26915741.0
=> {:events=>3131647.7, :fanout=>1234271.5, :default=>17179872, :detonation=>705552.8, :assets=>4664397}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment