Module: NBA::PlayerCompare

Defined in:
lib/nba/player_compare.rb

Overview

Provides methods to compare two players

Constant Summary collapse

OVERALL_COMPARE =

Result set name for overall comparison

Returns:

  • (String)

    the result set name

"OverallCompare".freeze
REGULAR_SEASON =

Season type constant for regular season

Returns:

  • (String)

    the season type

"Regular Season".freeze
PLAYOFFS =

Season type constant for playoffs

Returns:

  • (String)

    the season type

"Playoffs".freeze

Class Method Summary collapse

Class Method Details

.compare(player:, vs_player:, season: Utils.current_season, season_type: REGULAR_SEASON, client: CLIENT) ⇒ Collection

Compares two players overall stats

Examples:

stats = NBA::PlayerCompare.compare(
  player: 201939,
  vs_player: 2544,
  season: 2024
)
stats.each { |s| puts "#{s.full_name}: #{s.pts} ppg" }

Parameters:

  • player (Integer, Player)

    the first player ID or Player object

  • vs_player (Integer, Player)

    the second player ID or Player object

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

    the season year

  • season_type (String) (defaults to: REGULAR_SEASON)

    the season type

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of comparison stats



39
40
41
42
43
44
45
# File 'lib/nba/player_compare.rb', line 39

def self.compare(player:, vs_player:, season: Utils.current_season, season_type: REGULAR_SEASON, client: CLIENT)
  player_id = extract_player_id(player)
  vs_player_id = extract_player_id(vs_player)
  path = build_path(player_id, vs_player_id, season, season_type)
  response = client.get(path)
  parse_response(response)
end