class NHLScores::Game
Attributes
away_team[R]
away_team_score[R]
catv[R]
date[R]
home_team[R]
home_team_score[R]
id[R]
start_time[R]
status[R]
ustv[R]
Public Class Methods
new(game_attributes)
click to toggle source
# File lib/nhl_scores/game.rb, line 6 def initialize(game_attributes) @id = game_attributes["id"] @date = game_attributes["ts"] @start_time = game_attributes["bs"] @home_team = alter_team_name("#{game_attributes["htn"]} #{game_attributes["htv"].capitalize}") @away_team = alter_team_name("#{game_attributes["atn"]} #{game_attributes["atv"].capitalize}") @home_team_score = game_attributes["hts"] @away_team_score = game_attributes["ats"] @status = game_attributes["tsc"] @ustv = game_attributes["ustv"] @catv = game_attributes["catv"] end
Public Instance Methods
includes_team?(team_name)
click to toggle source
# File lib/nhl_scores/game.rb, line 64 def includes_team?(team_name) return home_team == team_name || away_team == team_name end
leader()
click to toggle source
# File lib/nhl_scores/game.rb, line 44 def leader not_in_progress_message high_score_team end
leader_score()
click to toggle source
# File lib/nhl_scores/game.rb, line 54 def leader_score not_in_progress_message high_score end
loser()
click to toggle source
# File lib/nhl_scores/game.rb, line 29 def loser not_final_message low_score_team end
loser_score()
click to toggle source
# File lib/nhl_scores/game.rb, line 39 def loser_score not_final_message low_score end
started?()
click to toggle source
# File lib/nhl_scores/game.rb, line 19 def started? return false if status.empty? || home_team_score.empty? || away_team_score.empty? return true end
team_name(team_abbrev)
click to toggle source
# File lib/nhl_scores/game.rb, line 68 def team_name(team_abbrev) return TEAM_ABBREVIATIONS[team_abbrev] end
trailer()
click to toggle source
# File lib/nhl_scores/game.rb, line 49 def trailer not_in_progress_message low_score_team end
trailer_score()
click to toggle source
# File lib/nhl_scores/game.rb, line 59 def trailer_score not_in_progress_message low_score end
winner()
click to toggle source
# File lib/nhl_scores/game.rb, line 24 def winner not_final_message high_score_team end
winner_score()
click to toggle source
# File lib/nhl_scores/game.rb, line 34 def winner_score not_final_message high_score end
Private Instance Methods
alter_team_name(team_name)
click to toggle source
# File lib/nhl_scores/game.rb, line 74 def alter_team_name(team_name) case team_name when "NY Rangers Rangers" return "New York Rangers" when "NY Islanders Islanders" return "New York Islanders" when "Toronto Mapleleafs" return "Toronto Maple Leafs" when "Columbus Bluejackets" return "Columbus Blue Jackets" when "Detroit Redwings" return "Detroit Red Wings" when "Vegas Goldenknights" return "Vegas Golden Knights" else return team_name end end
high_score()
click to toggle source
# File lib/nhl_scores/game.rb, line 93 def high_score return home_team_score if home_team_score == away_team_score home_team_score > away_team_score ? home_team_score : away_team_score end
high_score_team()
click to toggle source
# File lib/nhl_scores/game.rb, line 103 def high_score_team return home_team if home_team_score == away_team_score home_team_score > away_team_score ? home_team : away_team end
low_score()
click to toggle source
# File lib/nhl_scores/game.rb, line 98 def low_score return away_team_score if home_team_score == away_team_score home_team_score > away_team_score ? away_team_score : home_team_score end
low_score_team()
click to toggle source
# File lib/nhl_scores/game.rb, line 108 def low_score_team return away_team if home_team_score == away_team_score home_team_score > away_team_score ? away_team : home_team end
not_final_message()
click to toggle source
# File lib/nhl_scores/game.rb, line 113 def not_final_message "This game is not final." if status != "final" end
not_in_progress_message()
click to toggle source
# File lib/nhl_scores/game.rb, line 117 def not_in_progress_message "This game is not in progress." if status != "progress" end