lib/sportradar/api/nfl/game.rb in sportradar-api-0.1.32 vs lib/sportradar/api/nfl/game.rb in sportradar-api-0.1.33

- old
+ new

@@ -1,18 +1,20 @@ 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, :stats + 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, :week, :season def initialize(data) @response = data @id = data["id"] @status = data["status"] @reference = data["reference"] @number = data["number"] @scheduled = Time.parse(data["scheduled"]) if data["scheduled"] + @week = Sportradar::Api::Nfl::Week.new data.dig("summary", "week") if data.dig("summary", "week") + @season = Sportradar::Api::Nfl::Season.new data.dig("summary", "season") if data.dig("summary", "season") @entry_mode = data["entry_mode"] # game boxscore @number = data["number"] @attendance = data["attendance"] @@ -29,12 +31,12 @@ @last_event = Sportradar::Api::Nfl::Event.new data["last_event"]["event"] if data["last_event"] && data["last_event"]["event"] @scoring = Sportradar::Api::Nfl::Scoring.new data["scoring"] if data["scoring"] set_scoring_drives 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"] + @venue = Sportradar::Api::Nfl::Venue.new data["venue"] || location["venue"] if data["venue"] || location["venue"] + @home = Sportradar::Api::Nfl::Team.new data["home"] || location["home"] if data["home"] || location["home"] + @away = Sportradar::Api::Nfl::Team.new data["away"] || location["away"] if data["away"] || 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]