Class: SportsDataApi::Nba::Game

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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



6
7
8
9
10
11
12
13
# File 'lib/sports_data_api/nba/game.rb', line 6

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

Instance Attribute Details

#clockObject (readonly)

Returns the value of attribute clock.



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

def clock
  @clock
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#seasonObject (readonly)

Returns the value of attribute season.



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

def season
  @season
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

#yearObject (readonly)

Returns the value of attribute year.



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

def year
  @year
end

Instance Method Details

#away_teamObject



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

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

#away_team_idObject



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

def away_team_id
  json['away']['id']
end

#boxscoreObject

Wrapper for Nba.boxscore TODO

Raises:

  • (NotImplementedError)


66
67
68
# File 'lib/sports_data_api/nba/game.rb', line 66

def boxscore
  raise NotImplementedError
end

#broadcastObject



44
45
46
47
# File 'lib/sports_data_api/nba/game.rb', line 44

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

#home_teamObject



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

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

#home_team_idObject



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

def home_team_id
  json['home']['id']
end

#pbpObject

Wrapper for Nba.pbp (Nba.play_by_play) TODO

Raises:

  • (NotImplementedError)


59
60
61
# File 'lib/sports_data_api/nba/game.rb', line 59

def pbp
  raise NotImplementedError
end

#quarterObject



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

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

#scheduledObject



15
16
17
# File 'lib/sports_data_api/nba/game.rb', line 15

def scheduled
  @scheduled ||= Time.iso8601 json['scheduled']
end

#summaryObject

Wrapper for Nba.game_summary TODO



52
53
54
# File 'lib/sports_data_api/nba/game.rb', line 52

def summary
  Nba.game_summary(id)
end

#venueObject



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

def venue
  @venue ||= Venue.new(json['venue'])
end