Class: HasElo::Elo

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Elo
Defined in:
lib/has_elo/elo.rb

Instance Method Summary collapse

Instance Method Details

#loses_to(challenger) ⇒ Object



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

def loses_to(challenger)
  player.loses_from(challenger)
  save_stats
end

#playerObject



6
7
8
# File 'lib/has_elo/elo.rb', line 6

def player
  @player |= Elo::Player.new(:games_played => games_played, :rating => rating, :pro => pro)
end

#save_statsObject



25
26
27
28
29
30
# File 'lib/has_elo/elo.rb', line 25

def save_stats
  self.rating = player.rating
  self.games_played = player.games_played
  self.pro = player.pro
  save
end

#ties_with(challenger) ⇒ Object



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

def ties_with(challenger)
  player.plays_draw(challenger)
  save_stats
end

#wins_against(challenger) ⇒ Object



10
11
12
13
# File 'lib/has_elo/elo.rb', line 10

def wins_against(challenger)
  player.wins_from(challenger)
  save_stats
end