Module: NBA::PlayerIndex

Defined in:
lib/nba/player_index.rb

Overview

Provides methods to search and retrieve the player index

Constant Summary collapse

RESULT_SET_NAME =

Result set name for player index

Returns:

  • (String)

    the result set name

"PlayerIndex".freeze
HISTORICAL =

Historical flag: include historical players

Returns:

  • (Integer)

    the flag value

1
CURRENT =

Historical flag: current players only

Returns:

  • (Integer)

    the flag value

0

Class Method Summary collapse

Class Method Details

.all(season: Utils.current_season, historical: CURRENT, active: nil, all_star: nil, college: nil, country: nil, draft_pick: nil, draft_year: nil, height: nil, team: nil, weight: nil, client: CLIENT) ⇒ Collection

Retrieves the player index with optional filters

Examples:

# Get all current players
players = NBA::PlayerIndex.all
players.size #=> 450
# Get players from a specific college
duke_players = NBA::PlayerIndex.all(college: "Duke")
# Get players from a specific country
canadian = NBA::PlayerIndex.all(country: "Canada")

Parameters:

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

    the season year

  • historical (Integer) (defaults to: CURRENT)

    whether to include historical players (0 or 1)

  • active (String, nil) (defaults to: nil)

    filter by active status (“1” for active)

  • all_star (String, nil) (defaults to: nil)

    filter by all-star status

  • college (String, nil) (defaults to: nil)

    filter by college

  • country (String, nil) (defaults to: nil)

    filter by country

  • draft_pick (String, nil) (defaults to: nil)

    filter by draft pick

  • draft_year (String, nil) (defaults to: nil)

    filter by draft year

  • height (String, nil) (defaults to: nil)

    filter by height

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

    filter by team

  • weight (String, nil) (defaults to: nil)

    filter by weight

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of player index entries



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/nba/player_index.rb', line 53

def self.all(season: Utils.current_season, historical: CURRENT, active: nil, all_star: nil,
  college: nil, country: nil, draft_pick: nil, draft_year: nil, height: nil,
  team: nil, weight: nil, client: CLIENT)
  params = {season: season, historical: historical, active: active, all_star: all_star,
            college: college, country: country, draft_pick: draft_pick, draft_year: draft_year,
            height: height, team: team, weight: weight}
  path = build_path(params)
  ResponseParser.parse(client.get(path), result_set: RESULT_SET_NAME) do |data|
    build_entry(data)
  end
end