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

Inherits:
Object
  • Object
show all
Includes:
HTTParty
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(h) ⇒ Game

Returns a new instance of Game.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/nfl/live_update/game_center/game.rb', line 17

def initialize(h)
  @raw_json = h.to_json
  @raw_hash = JSON.parse(@raw_json)

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

  # new stuff found on saints 49 game live
  @clock = h["clock"]
  @down = h["down"]
  @drives = h["drives"]
  # id -> drive, crntdrv -> (id of current drive)
  @note = h["note"]
  @posteam = h["posteam"] # abbr for possessing team
  @quarter = h["qtr"]
  @redzone = h["redzone"] # bool
  @to_go = h["togo"] # 4th and 10 (the 10)
  @yard_line = h["yl"]
  # end of new
  #
  # new stuff found on an old game
  @media = h["media"]
  @scoring_summary = h["scrsummary"] # need more info
  @stadium = h["stadium"]
  @weather = h["weather"]
  # end of another new
end

Instance Attribute Details

#awayObject

Returns the value of attribute away.



14
15
16
# File 'lib/nfl/live_update/game_center/game.rb', line 14

def away
  @away
end

#homeObject

Returns the value of attribute home.



14
15
16
# File 'lib/nfl/live_update/game_center/game.rb', line 14

def home
  @home
end

#idObject

Returns the value of attribute id.



14
15
16
# File 'lib/nfl/live_update/game_center/game.rb', line 14

def id
  @id
end

#jsonObject

Returns the value of attribute json.



14
15
16
# File 'lib/nfl/live_update/game_center/game.rb', line 14

def json
  @json
end

#next_updateObject

Returns the value of attribute next_update.



14
15
16
# File 'lib/nfl/live_update/game_center/game.rb', line 14

def next_update
  @next_update
end

#raw_hashObject (readonly)

Returns the value of attribute raw_hash.



15
16
17
# File 'lib/nfl/live_update/game_center/game.rb', line 15

def raw_hash
  @raw_hash
end

#raw_jsonObject (readonly)

Returns the value of attribute raw_json.



15
16
17
# File 'lib/nfl/live_update/game_center/game.rb', line 15

def raw_json
  @raw_json
end

Class Method Details

.find(id) ⇒ Object



50
51
52
# File 'lib/nfl/live_update/game_center/game.rb', line 50

def find(id)
  new(get(relative_url(id)))
end