Skip to content

Instantly share code, notes, and snippets.

@drKreso
Created April 8, 2012 12:57
Show Gist options
  • Save drKreso/2337175 to your computer and use it in GitHub Desktop.
Save drKreso/2337175 to your computer and use it in GitHub Desktop.
Allocate_diff
def self.evenly(amount, number_of_slices)
- allocator = Allocate.new
- allocator.amount = amount
- allocator.ratios = (1..number_of_slices).map { |rata| 1.to_d/number_of_slices }
- allocator.divided
+ Allocate.new.tap do |a|
+ a.amount = amount
+ a.ratios = (1..number_of_slices).map { 1.to_d/number_of_slices }
+ end.divided
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment