Class: NFL::LiveUpdate::ScoreStrip::Games
- Inherits:
-
Object
- Object
- NFL::LiveUpdate::ScoreStrip::Games
- Defined in:
- lib/nfl/live_update/score_strip/games.rb
Constant Summary collapse
- LIVE_UPDATE_URL =
"http://www.nfl.com/liveupdate/scorestrip/ss.xml"
- AJAX_URL =
"http://www.nfl.com/ajax/scorestrip"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(xml) ⇒ Games
constructor
A new instance of Games.
Constructor Details
#initialize(xml) ⇒ Games
Returns a new instance of Games.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 9 def initialize(xml) gms = xml.xpath("//ss//gms").first @week = gms.attribute("w").value @year = gms.attribute("y").value @type = gms.attribute("t").value @gd = gms.attribute("gd").value @bph = gms.attribute("bph").value @games = gms.xpath("//g").map {|g| Game.new(g) } end |
Class Method Details
.current ⇒ Object
22 23 24 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 22 def current new(get(LIVE_UPDATE_URL)) end |
.get(url) ⇒ Object
37 38 39 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 37 def get(url) Nokogiri::XML(open(url)) end |
.url(params = {}) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 26 def url(params={}) season = params[:season] || Time.now.year season_type = params[:season_type] || "REG" week = params[:week] "#{AJAX_URL}?season=#{season}&seasonType=#{season_type}&week=#{week}" end |
.where(params) ⇒ Object
33 34 35 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 33 def where(params) new(get(url(params))) end |