Module: NBA::ScheduleInternational

Defined in:
lib/nba/schedule_international.rb

Overview

Provides methods to retrieve international league schedule

Constant Summary collapse

LEAGUE_SCHEDULE =

Result set name for league schedule

Returns:

  • (String)

    the result set name

"LeagueSchedule".freeze

Class Method Summary collapse

Class Method Details

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

Retrieves the international league schedule

Examples:

games = NBA::ScheduleInternational.all(season: 2024)
games.each { |g| puts "#{g.game_date}: #{g.away_team_name} @ #{g.home_team_name}" }

Parameters:

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

    the season year

  • 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 scheduled games



24
25
26
27
28
29
# File 'lib/nba/schedule_international.rb', line 24

def self.all(season: Utils.current_season, league: League::NBA, client: CLIENT)
  league_id = Utils.extract_league_id(league)
  path = build_path(season, league_id)
  response = client.get(path)
  parse_response(response)
end

.by_date(date:, season: Utils.current_season, league: League::NBA, client: CLIENT) ⇒ Collection

Retrieves international games for a specific date

Examples:

games = NBA::ScheduleInternational.by_date(date: Date.today, season: 2024)
games.each { |g| puts "#{g.away_team_name} @ #{g.home_team_name}" }

Parameters:

  • date (Date)

    the date

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

    the season year

  • 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 scheduled games



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

def self.by_date(date:, season: Utils.current_season, league: League::NBA, client: CLIENT)
  all_games = all(season: season, league: league, client: client)
  date_str = date.strftime
  filtered = all_games.select { |g| g.game_date&.start_with?(date_str) }
  Collection.new(filtered)
end

.by_team(team:, season: Utils.current_season, league: League::NBA, client: CLIENT) ⇒ Collection

Retrieves international games for a specific team

Examples:

games = NBA::ScheduleInternational.by_team(team: NBA::Team::GSW, season: 2024)
games.each { |g| puts "#{g.game_date}: #{g.away_team_tricode} @ #{g.home_team_tricode}" }

Parameters:

  • team (Integer, Team)

    the team ID or Team object

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

    the season year

  • 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 scheduled games



60
61
62
63
64
65
# File 'lib/nba/schedule_international.rb', line 60

def self.by_team(team:, season: Utils.current_season, league: League::NBA, client: CLIENT)
  team_id = extract_team_id(team)
  all_games = all(season: season, league: league, client: client)
  filtered = all_games.select { |g| g.home_team_id.eql?(team_id) || g.away_team_id.eql?(team_id) }
  Collection.new(filtered)
end