Module: NBA::HomePageLeaders

Defined in:
lib/nba/home_page_leaders.rb

Overview

Provides methods to retrieve NBA home page leaders

Constant Summary collapse

RESULT_SET =

Result set name for home page leaders

Returns:

  • (String)

    the result set name

"HomePageLeaders".freeze

Class Method Summary collapse

Class Method Details

.all(season: Utils.current_season, season_type: "Regular Season", stat_category: "PTS", game_scope: "Season", player_or_team: "Player", player_scope: "All Players", league: League::NBA, client: CLIENT) ⇒ Collection

Retrieves home page leaders for a season

Examples:

leaders = NBA::HomePageLeaders.all(season: 2023, stat_category: "PTS")
leaders.each { |l| puts "#{l.rank}. #{l.player}: #{l.pts}" }

Parameters:

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

    the season year

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

    the season type

  • stat_category (String) (defaults to: "PTS")

    the stat category (PTS, AST, REB, etc.)

  • game_scope (String) (defaults to: "Season")

    the game scope (Season, Yesterday, etc.)

  • player_or_team (String) (defaults to: "Player")

    player or team (Player, Team)

  • player_scope (String) (defaults to: "All Players")

    the player scope (All Players, Rookies)

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

    the league ID or League object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:



31
32
33
34
35
36
37
38
39
# File 'lib/nba/home_page_leaders.rb', line 31

def self.all(season: Utils.current_season, season_type: "Regular Season", stat_category: "PTS",
  game_scope: "Season", player_or_team: "Player", player_scope: "All Players",
  league: League::NBA, client: CLIENT)
  league_id = Utils.extract_league_id(league)
  opts = {season: season, season_type: season_type, stat_category: stat_category,
          game_scope: game_scope, player_or_team: player_or_team, player_scope: player_scope,
          league_id: league_id}
  ResponseParser.parse(client.get(build_path(opts)), result_set: RESULT_SET) { |data| build_leader(data) }
end