Module: NBA::ShotChart

Defined in:
lib/nba/shot_chart.rb

Overview

Provides methods to retrieve shot chart data

Constant Summary collapse

RESULT_SET_NAME =

Result set name for shot chart detail

Returns:

  • (String)

    the result set name

"Shot_Chart_Detail".freeze

Class Method Summary collapse

Class Method Details

.find(player:, team:, season: Utils.current_season, client: CLIENT) ⇒ Collection

Retrieves shot chart data for a player

Examples:

shots = NBA::ShotChart.find(player: 201939, team: Team::GSW)
shots.each { |s| puts "#{s.action_type} at (#{s.loc_x}, #{s.loc_y}): #{s.made? ? 'Made' : 'Missed'}" }

Parameters:

  • player (Integer, Player)

    the player ID or Player object

  • team (Integer, Team)

    the team ID or Team object

  • season (Integer) (defaults to: Utils.current_season)

    the season year (defaults to current season)

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:



24
25
26
27
28
# File 'lib/nba/shot_chart.rb', line 24

def self.find(player:, team:, season: Utils.current_season, client: CLIENT)
  path = "shotchartdetail?PlayerID=#{Utils.extract_id(player)}&TeamID=#{Utils.extract_id(team)}" \
         "&Season=#{Utils.format_season(season)}&ContextMeasure=FGA"
  ResponseParser.parse(client.get(path), result_set: RESULT_SET_NAME) { |data| build_shot(data) }
end