Class: PayoutSystem::WinnerTakesAll
- Defined in:
- lib/payout_system/winner_takes_all.rb
Instance Attribute Summary
Attributes inherited from Base
#entries, #logger, #options, #order, #pot
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from PayoutSystem::Base
Instance Method Details
#run ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/payout_system/winner_takes_all.rb', line 3 def run awards = [] max_value = entries.map(&order).max winning_entries = entries.select{|item|item.send(order) == max_value} return awards if winning_entries.empty? award_amount = pot / winning_entries.size # floor winning_entries.map{|t| [t,award_amount]} end |