class CrashingTheDance::RpiCalculator::OpponentGame
Attributes
game[R]
opponent[R]
opponent_score[R]
score[R]
team[R]
Public Class Methods
new(game, team)
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 5 def initialize(game, team) @game = game @team = team scores end
Public Instance Methods
conference?()
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 57 def conference? game.conference? end
home?()
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 49 def home? @which_team == :home && !neutral? end
loss?()
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 19 def loss? score < opponent_score end
losses()
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 27 def losses loss? ? 1 : 0 end
neutral?()
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 11 def neutral? game.neutral? end
rpi_losses()
click to toggle source
# 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()
click to toggle source
# 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?()
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 53 def visitor? @which_team == :visitor && !neutral? end
win?()
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 15 def win? score > opponent_score end
wins()
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 23 def wins win? ? 1 : 0 end
Private Instance Methods
assign_scores(score, opponent_score)
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 78 def assign_scores(score, opponent_score) fail "Both teams can't have the same score" if score == opponent_score @score = score @opponent_score = opponent_score end
scores()
click to toggle source
# File lib/crashing_the_dance/rpi_calculator/opponent_game.rb, line 63 def scores case when team.eql?(game.vis_team) @opponent = game.home_team @which_team = :visitor assign_scores(game.vis_score, game.home_score) when team.eql?(game.home_team) @opponent = game.vis_team assign_scores(game.home_score, game.vis_score) @which_team = :home else fail "Couldn't find #{team} in #{game}" end end