summaryrefslogtreecommitdiff
path: root/app/models/tournament_stage.rb
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-04-26 20:39:49 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-04-26 20:39:49 -0400
commited4f3dad6cd92710bf9cbafc36cf87dae8605f73 (patch)
tree40483a266f439e6fce717d38e3acd1edd4bdbf12 /app/models/tournament_stage.rb
parentdfbbe46fdcca392b3dec703cf347d1b1d57ca94f (diff)
add convenience methods for getting scoring/sampling/scheduling/seeding
Diffstat (limited to 'app/models/tournament_stage.rb')
-rw-r--r--app/models/tournament_stage.rb52
1 files changed, 14 insertions, 38 deletions
diff --git a/app/models/tournament_stage.rb b/app/models/tournament_stage.rb
index 0775305..9352137 100644
--- a/app/models/tournament_stage.rb
+++ b/app/models/tournament_stage.rb
@@ -2,6 +2,7 @@ class TournamentStage < ActiveRecord::Base
belongs_to :tournament
has_many :matches
+ # A 1-indexed hash of matches
def matches_ordered
h = {}
i = 1
@@ -13,57 +14,32 @@ class TournamentStage < ActiveRecord::Base
end
def create_matches
- set_scheduling
- @scheduling.create_matches
+ scheduling.create_matches
end
def to_svg(highlight_user)
- set_scheduling
- return @scheduling.graph(highlight_user)
+ return scheduling.graph(highlight_user)
end
- def pair
- set_pairing
- return @pairing.pair(matches, players)
+ def seed
+ return seeding.seed.pair(matches, players)
end
- def score
- set_scoring
- #populating the user scores in the database form what you get from @scoring.score(match, interface)
- end
+ # Accessors to the configured methods
- #populate the statistics interface (with populating method)
- def populate
- set_populating
- #?
+ def scoring
+ @scoring ||= tournament.scoring
end
- private
- def set_scheduling
- if @scheduling.nil?
- @scheduling = "Scheduling::#{self.scheduling.capitalize}".constantize.new(self)
- end
- return @scheduling
- end
-
- private
- def set_pairing
- if @pairing.nil?
- if(@tournament.randomized_teams)
- @pairing = "Pairing::RandomPairing"
- #elsif(setTeams)
- #@pairing = Pre built
- #return @pairing
- end
- end
- return @pairing
+ def sampling
+ @sampling ||= tournament.sampling
end
- private
- def set_scoring
+ def scheduling
+ @scheduling ||= "Scheduling::#{self.scheduling_method.camelcase}".constantize.new(self)
end
- private
- def set_populating
+ def seeding
+ @seeding ||= "Seeding::#{self.seeding_method.camelcase}".constantize.new(self)
end
end