lib/sportradar/api/nfl/game.rb in sportradar-api-0.1.31 vs lib/sportradar/api/nfl/game.rb in sportradar-api-0.1.32
- old
+ new
@@ -1,9 +1,9 @@
module Sportradar
module Api
class Nfl::Game < Data
- attr_accessor :response, :id, :status, :reference, :number, :scheduled, :entry_mode, :venue, :home, :away, :broadcast, :number, :attendance, :utc_offset, :weather, :clock, :quarter, :summary, :situation, :last_event, :scoring, :scoring_drives, :quarters
+ attr_accessor :response, :id, :status, :reference, :number, :scheduled, :entry_mode, :venue, :home, :away, :broadcast, :number, :attendance, :utc_offset, :weather, :clock, :quarter, :summary, :situation, :last_event, :scoring, :scoring_drives, :quarters, :stats
def initialize(data)
@response = data
@id = data["id"]
@@ -33,9 +33,14 @@
location = data["summary"] || data
@venue = Sportradar::Api::Nfl::Venue.new location["venue"] if location["venue"]
@home = Sportradar::Api::Nfl::Team.new location["home"] if location["home"]
@away = Sportradar::Api::Nfl::Team.new location["away"] if location["away"]
@broadcast = Sportradar::Api::Nfl::Broadcast.new data["broadcast"] if data["broadcast"]
+ if data["team"]
+ both_stats = data["team"].map { |hash| [hash["id"], Sportradar::Api::Nfl::GameStatistic.new(hash)] }.to_h
+ @home.stats = both_stats[@home.id]
+ @away.stats = both_stats[@away.id]
+ end
end
def current_score
"#{summary.home.points}-#{summary.away.points}" if summary
end