Class: NbaStats::Client

Constant Summary

Constants included from LeagueDashTeamStats

LeagueDashTeamStats::LEAGUE_DASH_TEAM_STATS_PATH

Constants included from PlayerGameLog

PlayerGameLog::PLAYER_GAME_LOG_PATH

Constants included from DraftCombineStats

DraftCombineStats::DRAFT_COMBINE_STATS_PATH

Constants included from DraftCombineSpotShooting

DraftCombineSpotShooting::DRAFT_COMBINE_SPOT_SHOOTING_PATH

Constants included from DraftCombineNonStationaryShooting

DraftCombineNonStationaryShooting::DRAFT_COMBINE_NON_STATIONARY_SHOOTING_PATH

Constants included from DraftCombineDrillResults

DraftCombineDrillResults::DRAFT_COMBINE_DRILL_RESULTS_PATH

Constants included from DraftCombinePlayerAnthro

DraftCombinePlayerAnthro::DRAFT_COMBINE_PLAYER_ANTHRO_PATH

Constants included from FranchiseHistory

FranchiseHistory::FRANCHISE_HISTORY_PATH

Constants included from HomePageLeaders

HomePageLeaders::HOME_PAGE_LEADERS_PATH

Constants included from PlayerCareerStats

PlayerCareerStats::PLAYER_CAREER_STATS_PATH

Constants included from LeagueDashPlayerStats

LeagueDashPlayerStats::LEAGUE_DASH_PLAYER_STATS_PATH

Constants included from LeagueDashLineups

LeagueDashLineups::LEAGUE_DASH_LINEUPS_PATH

Constants included from BoxScoreAdvanced

BoxScoreAdvanced::BOX_SCORE_ADVANCED_PATH

Constants included from BoxScoreMisc

BoxScoreMisc::BOX_SCORE_MISC_PATH

Constants included from BoxScoreScoring

BoxScoreScoring::BOX_SCORE_SCORING_PATH

Constants included from BoxScoreUsage

BoxScoreUsage::BOX_SCORE_USAGE_PATH

Constants included from BoxScoreFourFactors

BoxScoreFourFactors::BOX_SCORE_FOUR_FACTORS_PATH

Constants included from PlayByPlay

PlayByPlay::PLAY_BY_PLAY_PATH

Constants included from ShotChartDetail

ShotChartDetail::SHOT_CHART_DETAIL_PATH

Constants included from CommonTeamYears

NbaStats::CommonTeamYears::COMMON_TEAM_YEARS_PATH

Constants included from TeamYearByYearStats

TeamYearByYearStats::TEAM_YEAR_BY_YEAR_STATS_PATH

Constants included from TeamGameLog

TeamGameLog::TEAM_GAME_LOG_PATH

Constants included from CommonTeamRoster

NbaStats::CommonTeamRoster::COMMON_TEAM_ROSTER_PATH

Constants included from TeamInfoCommon

TeamInfoCommon::TEAM_INFO_COMMON_PATH

Constants included from PlayerDashboardByGeneralSplits

PlayerDashboardByGeneralSplits::PLAYER_DASHBOARD_BY_GENERAL_SPLITS_PATH

Constants included from PlayerProfile

PlayerProfile::PLAYER_PROFILE_PATH

Constants included from CommonPlayerInfo

NbaStats::CommonPlayerInfo::COMMON_PLAYER_INFO_PATH

Constants included from CommonAllPlayers

NbaStats::CommonAllPlayers::COMMON_ALL_PLAYERS_PATH

Constants included from BoxScore

BoxScore::BOX_SCORE_PATH

Constants included from Scoreboard

Scoreboard::SCOREBOARD_PATH

Instance Method Summary collapse

Methods included from LeagueDashTeamStats

#league_dash_team_stats

Methods included from PlayerGameLog

#player_game_log

Methods included from DraftCombineStats

#draft_combine_stats

Methods included from DraftCombineSpotShooting

#draft_combine_spot_shooting

Methods included from DraftCombineNonStationaryShooting

#draft_combine_non_stationary_shooting

Methods included from DraftCombineDrillResults

#draft_combine_drill_results

Methods included from DraftCombinePlayerAnthro

#draft_combine_player_anthro

Methods included from FranchiseHistory

#franchise_history

Methods included from HomePageLeaders

#home_page_leaders

Methods included from PlayerCareerStats

#player_career_stats

Methods included from LeagueDashPlayerStats

#league_dash_player_stats

Methods included from LeagueDashLineups

#league_dash_lineups

Methods included from BoxScoreAdvanced

#box_score_advanced

Methods included from BoxScoreMisc

#box_score_misc

Methods included from BoxScoreScoring

#box_score_scoring

Methods included from BoxScoreUsage

#box_score_usage

Methods included from BoxScoreFourFactors

#box_score_four_factors

Methods included from PlayByPlay

#play_by_play

Methods included from ShotChartDetail

#shot_chart_detail

Methods included from CommonTeamYears

#common_team_years

Methods included from TeamYearByYearStats

#team_year_by_year_stats

Methods included from TeamGameLog

#team_game_log

Methods included from CommonTeamRoster

#common_team_roster

Methods included from TeamInfoCommon

#team_info_common

Methods included from PlayerDashboardByGeneralSplits

#player_dashboard_by_general_splits

Methods included from PlayerProfile

#player_profile

Methods included from CommonPlayerInfo

#common_player_info

Methods included from CommonAllPlayers

#common_all_players

Methods included from BoxScore

#box_score

Methods included from Scoreboard

#scoreboard

Constructor Details

#initialize(options = {}) ⇒ NbaStats::Client

Initialize a new Client object

Parameters:

  • options (Hash) (defaults to: {})


78
79
80
81
82
83
84
85
86
87
88
# File 'lib/nba_stats/client.rb', line 78

def initialize(options={})
  # Merge the config values from the module and those passed
  # to the client.
  merged_options = NbaStats.options.merge(options)

  # Copy the merged values to this client and ignore those
  # not part of our configuration
  Configuration::VALID_CONFIG_KEYS.each do |key|
    send("#{key}=", merged_options[key])
  end
end

Instance Method Details

#get(path = '/', params = {}) ⇒ Hash

Perform a HTTP GET request

Parameters:

  • path (String) (defaults to: '/')
  • params (Hash) (defaults to: {})

Returns:

  • (Hash)


103
104
105
106
107
108
109
# File 'lib/nba_stats/client.rb', line 103

def get(path='/', params={})
  uri = Addressable::URI.new
  uri.query_values = params
  # Build the path with + instead of %20 because nba.com is flaky
  full_path = "#{path}?#{uri.query.gsub(/%20/,'+')}"
  request(:get, full_path)
end

#request_headersHash

Returns:

  • (Hash)


91
92
93
94
95
96
# File 'lib/nba_stats/client.rb', line 91

def request_headers
  @request_headers ||= {
      :accept => accept,
      :user_agent => user_agent
  }
end