Class: NHLScores::Game
- Inherits:
-
Object
- Object
- NHLScores::Game
- Defined in:
- lib/nhl_scores/game.rb
Instance Attribute Summary collapse
-
#away_team ⇒ Object
readonly
Returns the value of attribute away_team.
-
#away_team_score ⇒ Object
readonly
Returns the value of attribute away_team_score.
-
#catv ⇒ Object
readonly
Returns the value of attribute catv.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#home_team ⇒ Object
readonly
Returns the value of attribute home_team.
-
#home_team_score ⇒ Object
readonly
Returns the value of attribute home_team_score.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#ustv ⇒ Object
readonly
Returns the value of attribute ustv.
Instance Method Summary collapse
- #includes_team?(team_name) ⇒ Boolean
-
#initialize(game_attributes) ⇒ Game
constructor
A new instance of Game.
- #leader ⇒ Object
- #leader_score ⇒ Object
- #loser ⇒ Object
- #loser_score ⇒ Object
- #started? ⇒ Boolean
- #team_name(team_abbrev) ⇒ Object
- #trailer ⇒ Object
- #trailer_score ⇒ Object
- #winner ⇒ Object
- #winner_score ⇒ Object
Constructor Details
#initialize(game_attributes) ⇒ Game
Returns a new instance of Game.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nhl_scores/game.rb', line 8 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 |
Instance Attribute Details
#away_team ⇒ Object (readonly)
Returns the value of attribute away_team.
3 4 5 |
# File 'lib/nhl_scores/game.rb', line 3 def away_team @away_team end |
#away_team_score ⇒ Object (readonly)
Returns the value of attribute away_team_score.
3 4 5 |
# File 'lib/nhl_scores/game.rb', line 3 def away_team_score @away_team_score end |
#catv ⇒ Object (readonly)
Returns the value of attribute catv.
3 4 5 |
# File 'lib/nhl_scores/game.rb', line 3 def catv @catv end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
3 4 5 |
# File 'lib/nhl_scores/game.rb', line 3 def date @date end |
#home_team ⇒ Object (readonly)
Returns the value of attribute home_team.
3 4 5 |
# File 'lib/nhl_scores/game.rb', line 3 def home_team @home_team end |
#home_team_score ⇒ Object (readonly)
Returns the value of attribute home_team_score.
3 4 5 |
# File 'lib/nhl_scores/game.rb', line 3 def home_team_score @home_team_score end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/nhl_scores/game.rb', line 3 def id @id end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
3 4 5 |
# File 'lib/nhl_scores/game.rb', line 3 def start_time @start_time end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/nhl_scores/game.rb', line 3 def status @status end |
#ustv ⇒ Object (readonly)
Returns the value of attribute ustv.
3 4 5 |
# File 'lib/nhl_scores/game.rb', line 3 def ustv @ustv end |
Instance Method Details
#includes_team?(team_name) ⇒ Boolean
66 67 68 |
# File 'lib/nhl_scores/game.rb', line 66 def includes_team?(team_name) return home_team == team_name || away_team == team_name end |
#leader ⇒ Object
46 47 48 49 |
# File 'lib/nhl_scores/game.rb', line 46 def leader high_score_team end |
#leader_score ⇒ Object
56 57 58 59 |
# File 'lib/nhl_scores/game.rb', line 56 def leader_score high_score end |
#loser ⇒ Object
31 32 33 34 |
# File 'lib/nhl_scores/game.rb', line 31 def loser low_score_team end |
#loser_score ⇒ Object
41 42 43 44 |
# File 'lib/nhl_scores/game.rb', line 41 def loser_score low_score end |
#started? ⇒ Boolean
21 22 23 24 |
# File 'lib/nhl_scores/game.rb', line 21 def started? return false if status.empty? || home_team_score.empty? || away_team_score.empty? return true end |
#team_name(team_abbrev) ⇒ Object
70 71 72 |
# File 'lib/nhl_scores/game.rb', line 70 def team_name(team_abbrev) return TEAM_ABBREV_MAP[team_abbrev] if TEAM_ABBREV_MAP.has_key?(team_abbrev) end |
#trailer ⇒ Object
51 52 53 54 |
# File 'lib/nhl_scores/game.rb', line 51 def trailer low_score_team end |
#trailer_score ⇒ Object
61 62 63 64 |
# File 'lib/nhl_scores/game.rb', line 61 def trailer_score low_score end |
#winner ⇒ Object
26 27 28 29 |
# File 'lib/nhl_scores/game.rb', line 26 def winner high_score_team end |
#winner_score ⇒ Object
36 37 38 39 |
# File 'lib/nhl_scores/game.rb', line 36 def winner_score high_score end |