Class: NHLScores::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/nhl_scores/game.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_teamObject (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_scoreObject (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

#catvObject (readonly)

Returns the value of attribute catv.



3
4
5
# File 'lib/nhl_scores/game.rb', line 3

def catv
  @catv
end

#dateObject (readonly)

Returns the value of attribute date.



3
4
5
# File 'lib/nhl_scores/game.rb', line 3

def date
  @date
end

#home_teamObject (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_scoreObject (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

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/nhl_scores/game.rb', line 3

def id
  @id
end

#start_timeObject (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

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/nhl_scores/game.rb', line 3

def status
  @status
end

#ustvObject (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

Returns:

  • (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

#leaderObject



46
47
48
49
# File 'lib/nhl_scores/game.rb', line 46

def leader
  not_in_progress_message
  high_score_team
end

#leader_scoreObject



56
57
58
59
# File 'lib/nhl_scores/game.rb', line 56

def leader_score
  not_in_progress_message
  high_score
end

#loserObject



31
32
33
34
# File 'lib/nhl_scores/game.rb', line 31

def loser
  not_final_message
  low_score_team
end

#loser_scoreObject



41
42
43
44
# File 'lib/nhl_scores/game.rb', line 41

def loser_score
  not_final_message
  low_score
end

#started?Boolean

Returns:

  • (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

#trailerObject



51
52
53
54
# File 'lib/nhl_scores/game.rb', line 51

def trailer
  not_in_progress_message
  low_score_team
end

#trailer_scoreObject



61
62
63
64
# File 'lib/nhl_scores/game.rb', line 61

def trailer_score
  not_in_progress_message
  low_score
end

#winnerObject



26
27
28
29
# File 'lib/nhl_scores/game.rb', line 26

def winner
  not_final_message
  high_score_team
end

#winner_scoreObject



36
37
38
39
# File 'lib/nhl_scores/game.rb', line 36

def winner_score
  not_final_message
  high_score
end