Class: EloRatings::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/elo_ratings/results.rb

Instance Method Summary collapse

Constructor Details

#initializeResults

Returns a new instance of Results.



3
4
5
6
# File 'lib/elo_ratings/results.rb', line 3

def initialize
  @c_bayeselo = CBayeselo.new
  @players = []
end

Instance Method Details

#add_game(player_1, player_2, result) ⇒ Object



8
9
10
# File 'lib/elo_ratings/results.rb', line 8

def add_game player_1, player_2, result
  @c_bayeselo.append index_for!(player_1), index_for!(player_2), result
end

#count_games_for(player) ⇒ Object



12
13
14
15
# File 'lib/elo_ratings/results.rb', line 12

def count_games_for player
  return 0 if !exists? player
  @c_bayeselo.count_games(index_for(player)).to_i
end

#elo_for(player) ⇒ Object



17
18
19
20
# File 'lib/elo_ratings/results.rb', line 17

def elo_for player
  return nil if !exists? player
  @c_bayeselo.get_elo index_for(player)
end