Class: Xmlstats::Endpoints::NbaLeaders

Inherits:
Object
  • Object
show all
Includes:
Xmlstats::Endpoint
Defined in:
lib/xmlstats/endpoints/nba_leaders.rb

Constant Summary collapse

CATEGORIES =
%w(
  points_per_game
  assists_per_game
  rebounds_per_game
  off_rebounds_per_game
  def_rebounds_per_game
  field_goal_pct
  free_throw_pct
  three_point_pct
  blocks_per_game
  steals_per_game
  assists_to_turnovers_per_game
  steals_to_turnovers_per_game
  minutes_per_game
  games_played
)

Class Method Summary collapse

Methods included from Xmlstats::Endpoint

included

Class Method Details

.fetch(category_id = nil, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/xmlstats/endpoints/nba_leaders.rb', line 22

def self.fetch(category_id = nil, options = {})
  unless CATEGORIES.include? category_id.to_s
    raise "unknown category id #{category_id.inspect}, must be one of: #{CATEGORIES.inspect}"
  end

  response = fetch_json("nba/leaders/#{category_id}", options)

  response.map do |leader|
    Xmlstats::Objects::NbaLeader.new leader.merge(category_id: category_id.to_s)
  end
end