Skip to content

Commit

Permalink
Add getRankings method for basketball
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Jew authored and Bryan Jew committed Aug 11, 2015
1 parent 61b1373 commit 02585ff
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "node-sportsdata",
"description": "A wrapper for the SportsData API",
"version": "0.3.7",
"version": "0.3.8",
"homepage": "https://github.com/pac12/node-sportsdata",
"author": {
"name": "PAC-12",
Expand Down
25 changes: 25 additions & 0 deletions src/lib/v3/ncaamb.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ class NCAAMB extends SportApi

[params, callback]

getRankings: (params,callback) ->
[params, callback] = this.getYearWeekParams params, callback
this.getResource '/polls/AP/%(year)s/rankings.xml', params, callback

getYearWeekParams: (params, callback) ->
if typeof params is 'function'
callback = params
params = {}
if not params
params = {}

if not params.year
now = new Date()
year = now.getFullYear()
start = new Date(now.getFullYear(),0,0)
diff = now - start
oneDay = 1000 * 60 * 60 * 24
day = Math.floor(diff / oneDay)
if day > 180
params.year = year
else
params.year = year - 1

[params, callback]

###
TournamentID based functions
Expand Down

0 comments on commit 02585ff

Please sign in to comment.