Module: NBA::Roster

Defined in:
lib/nba/roster.rb

Overview

Provides methods to retrieve team rosters

Class Method Summary collapse

Class Method Details

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

Finds the roster for a team

Examples:

roster = NBA::Roster.find(team: NBA::Team::GSW)
roster.each { |player| puts player.full_name }

Parameters:

  • 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:

  • (Collection)

    a collection of players on the roster



19
20
21
22
# File 'lib/nba/roster.rb', line 19

def self.find(team:, season: Utils.current_season, client: CLIENT)
  path = "commonteamroster?TeamID=#{Utils.extract_id(team)}&Season=#{Utils.format_season(season)}"
  ResponseParser.parse(client.get(path)) { |data| build_player(data) }
end