lib/sportradar/api/nfl/game.rb in sportradar-api-0.9.8 vs lib/sportradar/api/nfl/game.rb in sportradar-api-0.9.9

- 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, :stats, :week, :season + 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, :overtime def initialize(data) @response = data @id = data["id"] @@ -22,14 +22,19 @@ @weather = data["weather"] @clock = data["clock"] if data["quarter"] @quarter = data["quarter"][0] - quarter_data = data["quarter"][1].is_a?(Hash) ? [ data["quarter"][1] ] : data["quarter"][1] + quarter_data = data["quarter"][1].is_a?(Hash) ? data["quarter"][1..-1] : data["quarter"][1] @quarters = quarter_data&.map { |hash| Sportradar::Api::Nfl::Quarter.new(hash) } end + if data["overtime"] + @overtime = parse_into_array(selector: data['overtime'], klass: Sportradar::Api::Nfl::Quarter) + @quarters.concat(@overtime) + end + @summary = Sportradar::Api::Nfl::Summary.new data["summary"] if data["summary"] @situation = Sportradar::Api::Nfl::Situation.new data["situation"] if data["situation"] @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"] @@ -46,9 +51,13 @@ @stats = data["team"].map { |team_stat| [team_stat["id"], Sportradar::Api::Nfl::GameStatistic.new(team_stat)] }.to_h @home.stats = @stats[@home.id] @away.stats = @stats[@away.id] end + end + + def overtime? + !overtime.nil? end def full_name "#{away.full_name} vs #{home.full_name}" end