lib/sportradar/api/soccer/match.rb in sportradar-api-0.17.2 vs lib/sportradar/api/soccer/match.rb in sportradar-api-0.17.3
- old
+ new
@@ -53,10 +53,11 @@
if (stats = data.dig('statistics', 'totals', 'competitors'))
update_teams(stats)
end
@scheduled = Time.parse(data['scheduled']) if data['scheduled']
+ @scheduled = Time.parse(data['start_time']) if data['start_time']
@start_time_tbd = data['start_time_tbd'] if data.key?('start_time_tbd')
@status = data['status'] if data['status']
@match_status = data['match_status'] if data['match_status']
@tournament_round = data['tournament_round'] if data['tournament_round']
@venue = Venue.new(data['venue']) if data['venue']
@@ -64,12 +65,14 @@
@referee = OpenStruct.new(data["referee"]) if data["referee"]
@coverage_info = OpenStruct.new(data["coverage_info"]) if data["coverage_info"]
@home_score = data['home_score'] if data['home_score']
@away_score = data['away_score'] if data['away_score']
+ @period = parse_period(data['match_status']) if data['match_status']
@period = data['period'] if data['period']
@match_time = data.dig('clock', 'match_time') if data.dig('clock', 'match_time')
+ @match_time = data.dig('clock', 'played') if data.dig('clock', 'played')
@stoppage_time = data.dig('clock', 'stoppage_time')
@ball_locations = data['ball_locations'] if data['ball_locations']
@winner_id = data['winner_id'] if data['winner_id']
@aggregate_home_score = data['aggregate_home_score'] if data['aggregate_home_score']
@@ -124,9 +127,22 @@
end
end
def halftime?
@match_status == "halftime"
+ end
+
+ def parse_period(status)
+ case status
+ when '1st_half', 'halftime'
+ 1
+ when '2nd_half'
+ 2
+ when 'overtime', '1st_extra'
+ 3
+ when '2nd_extra'
+ 4
+ end
end
def postponed?
'postponed' == status
end