Class: NFL::LiveUpdate::GameCenter::Team

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Team

Returns a new instance of Team.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/nfl/live_update/game_center/team.rb', line 8

def initialize(json)
  @abbr = json["abbr"]
  @time_outs = json["to"]
  @players = json["players"]

  @score = TeamScore.new(json["score"])
  @stats = json["stats"]
  @stats.each do |k,v|
    self.class.class_eval do
      define_method("#{k}_stats") do
        @stats[k]
      end
    end
    @stats[k] = if k == "team"
                  TeamStat.new(@stats[k])
                else
                  @stats[k].map do |k2,v2|
                    PlayerStat.new(k2, v2)
                  end
                end
  end
end

Instance Attribute Details

#abbrObject

Returns the value of attribute abbr.



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

def abbr
  @abbr
end

#playersObject

Returns the value of attribute players.



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

def players
  @players
end

#scoreObject

Returns the value of attribute score.



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

def score
  @score
end

#statsObject

Returns the value of attribute stats.



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

def stats
  @stats
end

#time_outsObject

Returns the value of attribute time_outs.



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

def time_outs
  @time_outs
end