Class: Tournament
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Tournament
- Defined in:
- lib/opensprints-core/tournament.rb
Instance Method Summary collapse
- #autofill(racer_list = nil) ⇒ Object
- #matched_racers ⇒ Object
-
#never_raced_and_not_eliminated ⇒ Object
TODO: test.
- #unmatched_racers ⇒ Object
- #unregistered_racers ⇒ Object
Instance Method Details
#autofill(racer_list = nil) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/opensprints-core/tournament.rb', line 10 def autofill(racer_list=nil) racer_list ||= reload.unmatched_racers.to_a racer_list.each_slice($BIKES.length) { |a| race = Race.create(:tournament => self) a.map{|r| RaceParticipation.create(:racer => r, :race => race)} } end |
#matched_racers ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/opensprints-core/tournament.rb', line 22 def matched_racers matched = [] matches = self.races.select{|race| race.unraced? } matches.each { |race| race.race_participations.each {|rp| matched << rp.racer } } matched end |
#never_raced_and_not_eliminated ⇒ Object
TODO: test
34 35 36 37 38 39 40 41 42 |
# File 'lib/opensprints-core/tournament.rb', line 34 def never_raced_and_not_eliminated matched = [] races.each { |race| race.race_participations.each {|rp| matched << rp.racer } } racers - matched - tournament_participations.select{|tp|tp.eliminated}.map{|tp|tp.racer} end |
#unmatched_racers ⇒ Object
18 19 20 |
# File 'lib/opensprints-core/tournament.rb', line 18 def unmatched_racers racers - matched_racers - tournament_participations.select{|tp|tp.eliminated}.map{|tp|tp.racer} end |