Module: Rubybooty
- Defined in:
- lib/rubybooty.rb
Defined Under Namespace
Classes: Array
Class Method Summary collapse
Class Method Details
.run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rubybooty.rb', line 11 def self.run entrants = {} while true while true name = ask("Entrants name (enter 'done' to finish): ") break if name.downcase == "done" entries = ask("Number of entries: (integer only)", Integer) entrants[name] = entries end sum = entrants.values.inject(0,&:+) if agree("Total entries: #{sum}\nRun now? (yes/no)") break end end entries = [] entrants.each { |k,v| v.times { entries << k }} winner = entries.shuffle!.first if winner puts "#{winner} is the winner! AARRR!" else puts "No winner." end end |