Class: SportsDataApi::Nhl::Game

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json:, year: nil, season: nil) ⇒ Game

Returns a new instance of Game.



7
8
9
10
11
12
13
14
15
16
# File 'lib/sports_data_api/nhl/game.rb', line 7

def initialize(json:, year: nil, season: nil)
  @json = json
  @year = year
  @season = season
  @id = json['id']
  @home_team_id = json['home']['id']
  @away_team_id = json['away']['id']
  @status = json['status']
  @clock = json['clock']
end

Instance Attribute Details

#away_team_idObject (readonly)

Returns the value of attribute away_team_id.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def away_team_id
  @away_team_id
end

#clockObject (readonly)

Returns the value of attribute clock.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def clock
  @clock
end

#home_team_idObject (readonly)

Returns the value of attribute home_team_id.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def home_team_id
  @home_team_id
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def id
  @id
end

#seasonObject (readonly)

Returns the value of attribute season.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def season
  @season
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def status
  @status
end

#yearObject (readonly)

Returns the value of attribute year.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def year
  @year
end

Instance Method Details

#away_teamObject



31
32
33
# File 'lib/sports_data_api/nhl/game.rb', line 31

def away_team
  @away_team ||= Team.new(json['away'])
end

#boxscoreObject

Wrapper for Nhl.boxscore TODO

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/sports_data_api/nhl/game.rb', line 61

def boxscore
  raise NotImplementedError
end

#broadcastObject



35
36
37
38
# File 'lib/sports_data_api/nhl/game.rb', line 35

def broadcast
  return if json['broadcast'].nil? || json['broadcast'].empty?
  @broadcast ||= Broadcast.new(json['broadcast'])
end

#home_teamObject



27
28
29
# File 'lib/sports_data_api/nhl/game.rb', line 27

def home_team
  @home_team ||= Team.new(json['home'])
end

#pbpObject

Wrapper for Nhl.pbp (Nhl.play_by_play) TODO

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/sports_data_api/nhl/game.rb', line 54

def pbp
  raise NotImplementedError
end

#periodObject



18
19
20
21
# File 'lib/sports_data_api/nhl/game.rb', line 18

def period
  return unless json['period']
  json['period'].to_i
end

#scheduledObject



23
24
25
# File 'lib/sports_data_api/nhl/game.rb', line 23

def scheduled
  @scheduled = Time.parse(json['scheduled'])
end

#summaryObject

Wrapper for Nhl.game_summary



47
48
49
# File 'lib/sports_data_api/nhl/game.rb', line 47

def summary
  Nhl.game_summary(id)
end

#venueObject



40
41
42
43
# File 'lib/sports_data_api/nhl/game.rb', line 40

def venue
  return if json['venue'].nil? || json['venue'].empty?
  @venue ||= Venue.new(json['venue'])
end