class Elo4m::Rating
Attributes
expected[R]
old_rating[R]
other_rating[R]
Public Class Methods
new(args = {})
click to toggle source
# File lib/elo4m/rating.rb, line 7 def initialize(args = {}) args.each do |key, value| instance_variable_set("@#{key}", value) end end
Public Instance Methods
expected_al()
click to toggle source
The expected score is the probably outcome of the match, depending on the difference in rating between the two players.
# File lib/elo4m/rating.rb, line 19 def expected_al 1.0 / ( 1.0 + ( 10.0 ** ((other_rating.to_f - old_rating.to_f) / 400.0) ) ) end
new_rating()
click to toggle source
# File lib/elo4m/rating.rb, line 13 def new_rating (old_rating.to_f + change).to_i end
Private Instance Methods
change()
click to toggle source
# File lib/elo4m/rating.rb, line 33 def change expected = self.expected.nil? ? expected_al : self.expected Elo4m.config.k_factor.to_f * ( result.to_f - expected ) end
result()
click to toggle source
# File lib/elo4m/rating.rb, line 25 def result @result.to_f end
valid_result?()
click to toggle source
# File lib/elo4m/rating.rb, line 29 def valid_result? (0..1).include? @result end