class SportsDataApi::Nba::Game

Attributes

clock[R]
id[R]
json[R]
season[R]
status[R]
year[R]

Public Class Methods

new(json:, year: nil, season: nil) click to toggle source
# 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

Public Instance Methods

away_team() click to toggle source
# File lib/sports_data_api/nba/game.rb, line 31
def away_team
  @away_team ||= Team.new(json['away'])
end
away_team_id() click to toggle source
# File lib/sports_data_api/nba/game.rb, line 23
def away_team_id
  json['away']['id']
end
boxscore() click to toggle source

Wrapper for Nba.boxscore TODO

# File lib/sports_data_api/nba/game.rb, line 66
def boxscore
  raise NotImplementedError
end
broadcast() click to toggle source
# 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_team() click to toggle source
# File lib/sports_data_api/nba/game.rb, line 27
def home_team
  @home_team ||= Team.new(json['home'])
end
home_team_id() click to toggle source
# File lib/sports_data_api/nba/game.rb, line 19
def home_team_id
  json['home']['id']
end
pbp() click to toggle source

Wrapper for Nba.pbp (Nba.play_by_play) TODO

# File lib/sports_data_api/nba/game.rb, line 59
def pbp
  raise NotImplementedError
end
quarter() click to toggle source
# File lib/sports_data_api/nba/game.rb, line 35
def quarter
  return unless json['quarter']
  json['quarter'].to_i
end
scheduled() click to toggle source
# File lib/sports_data_api/nba/game.rb, line 15
def scheduled
  @scheduled ||= Time.iso8601 json['scheduled']
end
summary() click to toggle source

Wrapper for Nba.game_summary TODO

# File lib/sports_data_api/nba/game.rb, line 52
def summary
  Nba.game_summary(id)
end
venue() click to toggle source
# File lib/sports_data_api/nba/game.rb, line 40
def venue
  @venue ||= Venue.new(json['venue'])
end

Private Instance Methods

game_summary?() click to toggle source
# File lib/sports_data_api/nba/game.rb, line 74
def game_summary?
  !team_json.nil?
end
team_json() click to toggle source
# File lib/sports_data_api/nba/game.rb, line 78
def team_json
  @team_json ||= json['team']
end