Module: NBA::TeamDetails

Defined in:
lib/nba/team_details.rb

Overview

Provides methods to retrieve team details

Constant Summary collapse

TEAM_BACKGROUND =

Result set name for team background

"TeamBackground".freeze
TEAM_HISTORY =

Result set name for team history

"TeamHistory".freeze

Class Method Summary collapse

Class Method Details

.find(team:, client: CLIENT) ⇒ TeamDetail?

Retrieves detailed information for a team

Examples:

detail = NBA::TeamDetails.find(team: NBA::Team::GSW)
puts "#{detail.full_name} plays at #{detail.arena}"


27
28
29
30
31
32
# File 'lib/nba/team_details.rb', line 27

def self.find(team:, client: CLIENT)
  team_id = extract_team_id(team)
  path = "teamdetails?TeamID=#{team_id}"
  response = client.get(path)
  parse_detail_response(response)
end

.history(team:, client: CLIENT) ⇒ Collection

Retrieves historical records for a team

Examples:

history = NBA::TeamDetails.history(team: NBA::Team::GSW)
history.each { |h| puts "#{h.year}: #{h.wins}-#{h.losses}" }


43
44
45
46
47
48
# File 'lib/nba/team_details.rb', line 43

def self.history(team:, client: CLIENT)
  team_id = extract_team_id(team)
  path = "teamdetails?TeamID=#{team_id}"
  response = client.get(path)
  parse_history_response(response)
end