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"
- POST_SEASON_URL =
"http://www.nfl.com/liveupdate/scorestrip/postseason/ss.xml"
- AJAX_URL =
"http://www.nfl.com/ajax/scorestrip"
Instance Attribute Summary collapse
-
#bph ⇒ Object
readonly
Returns the value of attribute bph.
-
#games ⇒ Object
readonly
Returns the value of attribute games.
-
#gd ⇒ Object
readonly
Returns the value of attribute gd.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#week ⇒ Object
readonly
Returns the value of attribute week.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Class Method Summary collapse
- .get(url) ⇒ Object
- .post_season ⇒ Object
- .regular_season ⇒ Object
- .url(params = {}) ⇒ Object
- .where(params) ⇒ Object
Instance Method Summary collapse
-
#initialize(xml) ⇒ Games
constructor
A new instance of Games.
- #type_string ⇒ Object
Constructor Details
#initialize(xml) ⇒ Games
Returns a new instance of Games.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 13 def initialize(xml) gms = xml.xpath("//ss//gms").first attributes = gms.attributes attributes.each do |k,v| attributes[k] = v.text end @week = attributes["w"] @year = attributes["y"] @type = attributes["t"] @gd = attributes["gd"] @bph = attributes["bph"] @bf = attributes["bf"] @games = gms.xpath("//g").map {|g| Game.new(g) } end |
Instance Attribute Details
#bph ⇒ Object (readonly)
Returns the value of attribute bph.
11 12 13 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 11 def bph @bph end |
#games ⇒ Object (readonly)
Returns the value of attribute games.
11 12 13 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 11 def games @games end |
#gd ⇒ Object (readonly)
Returns the value of attribute gd.
11 12 13 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 11 def gd @gd end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 11 def type @type end |
#week ⇒ Object (readonly)
Returns the value of attribute week.
11 12 13 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 11 def week @week end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
11 12 13 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 11 def year @year end |
Class Method Details
.get(url) ⇒ Object
63 64 65 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 63 def get(url) Nokogiri::XML(open(url)) end |
.post_season ⇒ Object
48 49 50 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 48 def post_season new(get(POST_SEASON_URL)) end |
.regular_season ⇒ Object
44 45 46 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 44 def regular_season new(get(LIVE_UPDATE_URL)) end |
.url(params = {}) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 52 def url(params={}) season = params[:season] season_type = params[:season_type] week = params[:week] "#{AJAX_URL}?season=#{season}&seasonType=#{season_type}&week=#{week}" end |
.where(params) ⇒ Object
59 60 61 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 59 def where(params) new(get(url(params))) end |
Instance Method Details
#type_string ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 31 def type_string case @type when "R" "Regular Season" when "POST" "Post Season" else @type end end |