Module: NBA::PlayByPlay

Defined in:
lib/nba/play_by_play.rb

Overview

Provides methods to retrieve play-by-play data for games

Constant Summary collapse

RESULT_SET_NAME =

Result set name for play-by-play data

Returns:

  • (String)

    the result set name

"PlayByPlay".freeze

Class Method Summary collapse

Class Method Details

.find(game:, start_period: 1, end_period: 10, client: CLIENT) ⇒ Collection

Retrieves play-by-play data for a game

Examples:

plays = NBA::PlayByPlay.find(game: "0022400001")
plays.each { |p| puts "#{p.pc_time_string}: #{p.description}" }

Parameters:

  • game (String, Game)

    the game ID or Game object

  • start_period (Integer) (defaults to: 1)

    the starting period (default 1)

  • end_period (Integer) (defaults to: 10)

    the ending period (default 10)

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:



24
25
26
27
# File 'lib/nba/play_by_play.rb', line 24

def self.find(game:, start_period: 1, end_period: 10, client: CLIENT)
  path = "playbyplayv2?GameID=#{Utils.extract_id(game)}&StartPeriod=#{start_period}&EndPeriod=#{end_period}"
  ResponseParser.parse(client.get(path), result_set: RESULT_SET_NAME) { |data| build_play(data) }
end