Module: NBA::WinProbability

Defined in:
lib/nba/win_probability.rb

Overview

Provides methods to retrieve win probability data

Constant Summary collapse

WIN_PROB_PBP =

Result set name for win probability

Returns:

  • (String)

    the result set name

"WinProbPBP".freeze

Class Method Summary collapse

Class Method Details

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

Retrieves win probability data for a game

Examples:

points = NBA::WinProbability.find(game: "0022400001")
points.each { |p| puts "Period #{p.period}: Home #{(p.home_pct * 100).round}%" }

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 win probability points



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

def self.find(game:, client: CLIENT)
  game_id = Utils.extract_id(game)
  path = "winprobabilitypbp?GameID=#{game_id}&LeagueID=00"
  response = client.get(path)
  parse_response(response, game_id)
end