Class: EasyElo::Game
Instance Method Summary collapse
-
#initialize(p1, p2) ⇒ Game
constructor
A new instance of Game.
- #won_by(winner) ⇒ Object
Constructor Details
#initialize(p1, p2) ⇒ Game
Returns a new instance of Game.
5 6 7 8 9 |
# File 'lib/easy_elo/game.rb', line 5 def initialize(p1, p2) @p1 = p1 @p2 = p2 @result = nil end |
Instance Method Details
#won_by(winner) ⇒ Object
11 12 13 14 15 |
# File 'lib/easy_elo/game.rb', line 11 def won_by(winner) result = (winner = @p1 ? 1 : 0) @p1.plays(@p2, result) @p2.plays(@p1, result - 1) end |