Class: EloRankable::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/elo_rankable/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_ratingObject

Returns the value of attribute base_rating.



5
6
7
# File 'lib/elo_rankable/configuration.rb', line 5

def base_rating
  @base_rating
end

#k_factor_strategyObject (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(rating)
  case @k_factor_strategy
  when Proc
    @k_factor_strategy.call(rating)
  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