Class: NFL::LiveUpdate::ScoreStrip::Games
- Inherits:
-
Object
- Object
- NFL::LiveUpdate::ScoreStrip::Games
- Includes:
- HTTParty
- Defined in:
- lib/nfl/live_update/score_strip/games.rb
Constant Summary collapse
- 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
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.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 20 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.
18 19 20 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 18 def bph @bph end |
#games ⇒ Object (readonly)
Returns the value of attribute games.
18 19 20 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 18 def games @games end |
#gd ⇒ Object (readonly)
Returns the value of attribute gd.
18 19 20 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 18 def gd @gd end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
18 19 20 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 18 def type @type end |
#week ⇒ Object (readonly)
Returns the value of attribute week.
18 19 20 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 18 def week @week end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
18 19 20 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 18 def year @year end |
Class Method Details
.post_season ⇒ Object
56 57 58 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 56 def post_season new(get("/postseason/ss.xml")) end |
.regular_season ⇒ Object
52 53 54 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 52 def regular_season new(get("/ss.xml")) end |
.url(params = {}) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 60 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
67 68 69 70 71 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 67 def where(params) ajax_url = url(params) response = HTTParty.get(ajax_url) new(Nokogiri::XML(response.body)) end |
Instance Method Details
#type_string ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nfl/live_update/score_strip/games.rb', line 39 def type_string case @type when "R" "Regular Season" when "POST" "Post Season" else @type end end |