Module: NBA::FranchiseHistory

Defined in:
lib/nba/franchise_history.rb

Overview

Provides methods to retrieve franchise history

Constant Summary collapse

FRANCHISE_HISTORY =

Result set name for franchise history

Returns:

  • (String)

    the result set name

"FranchiseHistory".freeze
DEFUNCT_TEAMS =

Result set name for defunct teams

Returns:

  • (String)

    the result set name

"DefunctTeams".freeze

Class Method Summary collapse

Class Method Details

.all(league: League::NBA, client: CLIENT) ⇒ Collection

Retrieves all franchise history data

Examples:

franchises = NBA::FranchiseHistory.all
franchises.each { |f| puts "#{f.team_city} #{f.team_name}: #{f.league_titles} titles" }

Parameters:

  • league (String, League) (defaults to: League::NBA)

    the league ID or League object (default NBA)

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:



26
27
28
29
30
31
# File 'lib/nba/franchise_history.rb', line 26

def self.all(league: League::NBA, client: CLIENT)
  league_id = Utils.extract_league_id(league)
  path = "franchisehistory?LeagueID=#{league_id}"
  response = client.get(path)
  parse_response(response, FRANCHISE_HISTORY)
end

.defunct(league: League::NBA, client: CLIENT) ⇒ Collection

Retrieves defunct team history data

Examples:

defunct = NBA::FranchiseHistory.defunct
defunct.each { |f| puts "#{f.team_city} #{f.team_name}: #{f.start_year}-#{f.end_year}" }

Parameters:

  • league (String, League) (defaults to: League::NBA)

    the league ID or League object (default NBA)

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of defunct franchises



42
43
44
45
46
47
# File 'lib/nba/franchise_history.rb', line 42

def self.defunct(league: League::NBA, client: CLIENT)
  league_id = Utils.extract_league_id(league)
  path = "franchisehistory?LeagueID=#{league_id}"
  response = client.get(path)
  parse_response(response, DEFUNCT_TEAMS)
end