Class: EloRankable::Configuration
- Inherits:
-
Object
- Object
- EloRankable::Configuration
- Defined in:
- lib/elo_rankable/configuration.rb
Instance Attribute Summary collapse
-
#base_rating ⇒ Object
Returns the value of attribute base_rating.
-
#k_factor_strategy ⇒ Object
readonly
Returns the value of attribute k_factor_strategy.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #k_factor_for(rating) ⇒ Object
- #k_factor_for=(strategy) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 |
# File 'lib/elo_rankable/configuration.rb', line 8 def initialize @base_rating = 1200 @k_factor_strategy = default_k_factor_strategy end |
Instance Attribute Details
#base_rating ⇒ Object
Returns the value of attribute base_rating.
5 6 7 |
# File 'lib/elo_rankable/configuration.rb', line 5 def @base_rating end |
#k_factor_strategy ⇒ Object (readonly)
Returns the value of attribute k_factor_strategy.
6 7 8 |
# File 'lib/elo_rankable/configuration.rb', line 6 def k_factor_strategy @k_factor_strategy end |
Instance Method Details
#k_factor_for(rating) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/elo_rankable/configuration.rb', line 17 def k_factor_for() case @k_factor_strategy when Proc @k_factor_strategy.call() when Numeric @k_factor_strategy else raise ArgumentError, 'K-factor strategy must be a Proc or Numeric' end end |
#k_factor_for=(strategy) ⇒ Object
13 14 15 |
# File 'lib/elo_rankable/configuration.rb', line 13 def k_factor_for=(strategy) @k_factor_strategy = strategy end |