Class: NBA::Game
- Inherits:
-
Object
- Object
- NBA::Game
- Defined in:
- lib/nba/game.rb
Constant Summary collapse
- BASE_URI =
'http://data.nba.com/jsonp/5s/json/cms/noseason/scoreboard'
Class Method Summary collapse
Class Method Details
.get_games(date = today_date) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/nba/game.rb', line 4 def self.get_games(date=today_date) url = BASE_URI+"/#{date}/games.json?callback=cb" res = HTTP.get(url) if res.code == 200 # THE RESPONSE HERE IS JSONP, SO WE NEED TO PARSE IT len = res.body.to_s.length return JSON.parse(res.body.to_s[3,(len-5)]) end return res.code end |
.today_date ⇒ Object
16 17 18 19 |
# File 'lib/nba/game.rb', line 16 def self.today_date d = Date.today d.strftime('%Y%m%d') end |