Class: NBA::Player
- Inherits:
-
Object
- Object
- NBA::Player
- Defined in:
- lib/nba/player.rb
Constant Summary collapse
- BASE_URI =
'http://stats.nba.com/stats'
Class Method Summary collapse
- .current_season ⇒ Object
- .get_all_players(is_current_season = true, leagueId = '00', season_str = current_season) ⇒ Object
- .get_player(playerId, leagueId = '00') ⇒ Object
Class Method Details
.current_season ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nba/player.rb', line 28 def self.current_season #ROLL THE CURRENT SEASON WHEN WE REACH AUGUST if Date.today.month >= 8 last_year = Date.today.year.to_s cur_year = (Date.today.year+1).to_s[-2..-1] "#{last_year}-#{cur_year}" else last_year = (Date.today.year-1).to_s cur_year = Date.today.year.to_s[-2..-1] "#{last_year}-#{cur_year}" end end |
.get_all_players(is_current_season = true, leagueId = '00', season_str = current_season) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nba/player.rb', line 15 def self.get_all_players(is_current_season=true,leagueId='00',season_str=current_season) is_current_season = is_current_season ? 1 : 0 res = HTTP.get(BASE_URI+'/commonallplayers', :params => { :IsOnlyCurrentSeason => is_current_season, :LeagueID => leagueId, :Season => season_str }) if res.code == 200 return JSON.parse(res.body) end return res.code end |
.get_player(playerId, leagueId = '00') ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/nba/player.rb', line 4 def self.get_player(playerId, leagueId='00') res = HTTP.get(BASE_URI+'/commonplayerinfo', :params => { :LeagueID => leagueId, :PlayerID => playerId }) if res.code == 200 return JSON.parse(res.body) end return res.code end |