Module: NBA::Players
- Defined in:
- lib/nba/players.rb
Overview
Provides methods to retrieve NBA players
Class Method Summary collapse
-
.all(season: Utils.current_season, only_current: true, client: CLIENT) ⇒ Collection
Retrieves all NBA players.
-
.find(player_id, client: CLIENT) ⇒ Player?
Finds a player by ID.
Class Method Details
.all(season: Utils.current_season, only_current: true, client: CLIENT) ⇒ Collection
Retrieves all NBA players
19 20 21 22 23 |
# File 'lib/nba/players.rb', line 19 def self.all(season: Utils.current_season, only_current: true, client: CLIENT) current_flag = only_current ? 1 : 0 path = "commonallplayers?LeagueID=00&Season=#{Utils.format_season(season)}&IsOnlyCurrentSeason=#{current_flag}" ResponseParser.parse(client.get(path)) { |data| build_player_summary(data) } end |
.find(player_id, client: CLIENT) ⇒ Player?
Finds a player by ID
35 36 37 38 39 40 41 |
# File 'lib/nba/players.rb', line 35 def self.find(player_id, client: CLIENT) id = Utils.extract_id(player_id) return unless id path = "commonplayerinfo?PlayerID=#{id}" ResponseParser.parse_single(client.get(path)) { |data| build_player_detail(data) } end |