Module: Tournament::ScoringStrategy
- Defined in:
- lib/tournament/scoring_strategy.rb
Overview
Module namespace for various scoring strategies for tournament pools.
Defined Under Namespace
Classes: Basic, ConstantValue, JoshPatashnik, TweakedJoshPatashnik, Upset, WorldCupSoccer
Class Method Summary collapse
-
.available_strategies ⇒ Object
Returns names of available strategies.
-
.strategy_for_name(name) ⇒ Object
Returns an instantiated strategy class for the named strategy.
Class Method Details
.available_strategies ⇒ Object
Returns names of available strategies. The names returned are suitable for use in the strategy_for_name method
108 109 110 |
# File 'lib/tournament/scoring_strategy.rb', line 108 def self.available_strategies return ['basic', 'world_cup_soccer', 'upset', 'josh_patashnik', 'tweaked_josh_patashnik', 'constant_value'] end |
.strategy_for_name(name) ⇒ Object
Returns an instantiated strategy class for the named strategy.
113 114 115 116 |
# File 'lib/tournament/scoring_strategy.rb', line 113 def self.strategy_for_name(name) clazz = Tournament::ScoringStrategy.const_get(name.capitalize.gsub(/_([a-zA-Z])/) {|m| $1.upcase}) return clazz.new end |