Module: NBA::MatchupsRollup

Defined in:
lib/nba/matchups_rollup.rb

Overview

Provides methods to retrieve NBA matchup rollup statistics

Constant Summary collapse

RESULT_SET =

Result set name for matchups rollup

Returns:

  • (String)

    the result set name

"MatchupsRollup".freeze

Class Method Summary collapse

Class Method Details

.all(season: Utils.current_season, season_type: "Regular Season", per_mode: "Totals", def_player: nil, def_team: nil, off_player: nil, off_team: nil, league: League::NBA, client: CLIENT) ⇒ Collection

Retrieves matchup rollup statistics

Examples:

matchups = NBA::MatchupsRollup.all(season: 2023)
matchups.each { |m| puts "#{m.def_player_name}: #{m.matchup_fg_pct}" }

Parameters:

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

    the season year (defaults to current season)

  • season_type (String) (defaults to: "Regular Season")

    the season type (Regular Season, Playoffs, etc.)

  • per_mode (String) (defaults to: "Totals")

    the per mode (Totals, PerGame, etc.)

  • def_player (Integer, Player, nil) (defaults to: nil)

    the defensive player ID or Player object

  • def_team (Integer, Team, nil) (defaults to: nil)

    the defensive team ID or Team object

  • off_player (Integer, Player, nil) (defaults to: nil)

    the offensive player ID or Player object

  • off_team (Integer, Team, nil) (defaults to: nil)

    the offensive team ID or Team object

  • league (String, League) (defaults to: League::NBA)

    the league ID or League object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of matchup rollups



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/nba/matchups_rollup.rb', line 32

def self.all(season: Utils.current_season, season_type: "Regular Season",
  per_mode: "Totals", def_player: nil, def_team: nil, off_player: nil,
  off_team: nil, league: League::NBA, client: CLIENT)
  league_id = Utils.extract_league_id(league)
  opts = {season: season, season_type: season_type, per_mode: per_mode,
          def_player_id: Utils.extract_id(def_player), def_team_id: Utils.extract_id(def_team),
          off_player_id: Utils.extract_id(off_player), off_team_id: Utils.extract_id(off_team),
          league_id: league_id}
  ResponseParser.parse(client.get(build_path(opts)), result_set: RESULT_SET) do |data|
    build_matchup(data)
  end
end