Module: NBA::GameRotation

Defined in:
lib/nba/game_rotation.rb

Overview

Provides methods to retrieve game rotation data

Constant Summary collapse

HOME_TEAM =

Result set name for home team rotation

Returns:

  • (String)

    the result set name

"HomeTeam".freeze
AWAY_TEAM =

Result set name for away team rotation

Returns:

  • (String)

    the result set name

"AwayTeam".freeze

Class Method Summary collapse

Class Method Details

.all(game:, client: CLIENT) ⇒ Collection

Retrieves all rotation data for a game

Examples:

rotations = NBA::GameRotation.all(game: "0022400001")
rotations.each { |r| puts "#{r.team_name}: #{r.player_name}" }

Parameters:

  • game (String, Game)

    the game ID or Game object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of all rotation entries



59
60
61
62
63
# File 'lib/nba/game_rotation.rb', line 59

def self.all(game:, client: CLIENT)
  home = home_team(game: game, client: client).to_a
  away = away_team(game: game, client: client).to_a
  Collection.new(home + away)
end

.away_team(game:, client: CLIENT) ⇒ Collection

Retrieves rotation data for the away team in a game

Examples:

rotations = NBA::GameRotation.away_team(game: "0022400001")
rotations.each { |r| puts "#{r.player_name}: #{r.pt_diff} +/-" }

Parameters:

  • game (String, Game)

    the game ID or Game object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of rotation entries



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

def self.away_team(game:, client: CLIENT)
  game_id = extract_game_id(game)
  path = build_path(game_id)
  response = client.get(path)
  parse_response(response, AWAY_TEAM, game_id)
end

.home_team(game:, client: CLIENT) ⇒ Collection

Retrieves rotation data for the home team in a game

Examples:

rotations = NBA::GameRotation.home_team(game: "0022400001")
rotations.each { |r| puts "#{r.player_name}: #{r.player_pts} pts" }

Parameters:

  • game (String, Game)

    the game ID or Game object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of rotation entries



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

def self.home_team(game:, client: CLIENT)
  game_id = extract_game_id(game)
  path = build_path(game_id)
  response = client.get(path)
  parse_response(response, HOME_TEAM, game_id)
end