Class: CrashingTheDance::RpiCalculator::OpponentGame
- Inherits:
-
Object
- Object
- CrashingTheDance::RpiCalculator::OpponentGame
- Defined in:
- lib/crashing_the_dance/rpi_calculator/opponent_game.rb
Instance Attribute Summary collapse
-
#game ⇒ Object
readonly
Returns the value of attribute game.
-
#opponent ⇒ Object
readonly
Returns the value of attribute opponent.
-
#opponent_score ⇒ Object
readonly
Returns the value of attribute opponent_score.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#team ⇒ Object
readonly
Returns the value of attribute team.
Instance Method Summary collapse
- #home? ⇒ Boolean
-
#initialize(game, team) ⇒ OpponentGame
constructor
A new instance of OpponentGame.
- #loss? ⇒ Boolean
- #losses ⇒ Object
- #neutral? ⇒ Boolean
- #rpi_losses ⇒ Object
- #rpi_wins ⇒ Object
- #visitor? ⇒ Boolean
- #win? ⇒ Boolean
- #wins ⇒ Object
Constructor Details
#initialize(game, team) ⇒ OpponentGame
Returns a new instance of OpponentGame.
5 6 7 8 9 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 5 def initialize(game, team) @game = game @team = team scores end |
Instance Attribute Details
#game ⇒ Object (readonly)
Returns the value of attribute game.
4 5 6 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 4 def game @game end |
#opponent ⇒ Object (readonly)
Returns the value of attribute opponent.
4 5 6 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 4 def opponent @opponent end |
#opponent_score ⇒ Object (readonly)
Returns the value of attribute opponent_score.
4 5 6 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 4 def opponent_score @opponent_score end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
4 5 6 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 4 def score @score end |
#team ⇒ Object (readonly)
Returns the value of attribute team.
4 5 6 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 4 def team @team end |
Instance Method Details
#home? ⇒ Boolean
49 50 51 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 49 def home? @which_team == :home && !neutral? end |
#loss? ⇒ Boolean
19 20 21 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 19 def loss? score < opponent_score end |
#losses ⇒ Object
27 28 29 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 27 def losses loss? ? 1 : 0 end |
#neutral? ⇒ Boolean
11 12 13 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 11 def neutral? game.neutral? end |
#rpi_losses ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 40 def rpi_losses case when win? then 0.0 when visitor? then 0.6 when home? then 1.4 else 1.0 end end |
#rpi_wins ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 31 def rpi_wins case when loss? then 0.0 when home? then 0.6 when visitor? then 1.4 else 1.0 end end |
#visitor? ⇒ Boolean
53 54 55 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 53 def visitor? @which_team == :visitor && !neutral? end |
#win? ⇒ Boolean
15 16 17 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 15 def win? score > opponent_score end |
#wins ⇒ Object
23 24 25 |
# File 'lib/crashing_the_dance/rpi_calculator/opponent_game.rb', line 23 def wins win? ? 1 : 0 end |