Class: NFL::LiveUpdate::GameCenter::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/nfl/live_update/game_center/game.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Game

Returns a new instance of Game.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/nfl/live_update/game_center/game.rb', line 8

def initialize(json)
  @next_update = json.delete("nextupdate")
  @id = json.keys.first
  json = json[@id.to_s]
  @home = Team.new(json["home"])
  @away = Team.new(json["away"])

  @json = json
  @json.delete("home")
  @json.delete("away")
end

Instance Attribute Details

#awayObject

Returns the value of attribute away.



6
7
8
# File 'lib/nfl/live_update/game_center/game.rb', line 6

def away
  @away
end

#homeObject

Returns the value of attribute home.



6
7
8
# File 'lib/nfl/live_update/game_center/game.rb', line 6

def home
  @home
end

#jsonObject

Returns the value of attribute json.



6
7
8
# File 'lib/nfl/live_update/game_center/game.rb', line 6

def json
  @json
end

Class Method Details

.test_gameObject



22
23
24
25
26
# File 'lib/nfl/live_update/game_center/game.rb', line 22

def test_game
  eid = "2011122500"
  url = "http://www.nfl.com/liveupdate/game-center/#{eid}/#{eid}_gtd.json"
  new(JSON.parse(open(url).readlines.join))
end