Module: NBA::FantasyWidget

Defined in:
lib/nba/fantasy_widget.rb

Overview

Provides methods to retrieve NBA fantasy widget statistics

Constant Summary collapse

RESULT_SET =

Result set name for fantasy widget

Returns:

  • (String)

    the result set name

"FantasyWidgetResult".freeze

Class Method Summary collapse

Class Method Details

.all(season: Utils.current_season, season_type: "Regular Season", active_players: "Y", last_n_games: 0, league: League::NBA, client: CLIENT) ⇒ Collection

Retrieves fantasy widget player statistics

Examples:

players = NBA::FantasyWidget.all(season: 2023)
players.each { |p| puts "#{p.player_name}: #{p.fan_duel_pts}" }

Parameters:

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

    the season year (defaults to current season)

  • season_type (String) (defaults to: "Regular Season")

    the season type (Regular Season, Playoffs, etc.)

  • active_players (String) (defaults to: "Y")

    active players filter (Y, N)

  • last_n_games (Integer) (defaults to: 0)

    filter to last N games

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

    the league ID or League object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of fantasy widget players



29
30
31
32
33
34
35
36
37
# File 'lib/nba/fantasy_widget.rb', line 29

def self.all(season: Utils.current_season, season_type: "Regular Season",
  active_players: "Y", last_n_games: 0, league: League::NBA, client: CLIENT)
  league_id = Utils.extract_league_id(league)
  opts = {season: season, season_type: season_type, active_players: active_players,
          last_n_games: last_n_games, league_id: league_id}
  ResponseParser.parse(client.get(build_path(opts)), result_set: RESULT_SET) do |data|
    build_player(data)
  end
end