Class: Elo::Rating

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/elo/rating.rb

Overview

This class calculates the rating between two players, but only from one persons perspective. You need two Rating-instances to calculate ratings for both players. Luckily, Elo::Game handles this for you automatically.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

included, #initialize

Instance Attribute Details

#k_factorObject (readonly)

The k-factor you wish to use for this calculation.



18
19
20
# File 'lib/elo/rating.rb', line 18

def k_factor
  @k_factor
end

#old_ratingObject (readonly)

The rating of the player you wish to calculate.



15
16
17
# File 'lib/elo/rating.rb', line 15

def old_rating
  @old_rating
end

#other_ratingObject (readonly)

The rating of the player you DON“T wish to calculate.



12
13
14
# File 'lib/elo/rating.rb', line 12

def other_rating
  @other_rating
end

Instance Method Details

#new_ratingObject

The new rating is… wait for it… the new rating!



21
22
23
# File 'lib/elo/rating.rb', line 21

def new_rating
  old_rating + change.round
end