-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
2,427 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
module Sportradar | ||
module Api | ||
module Football | ||
class Drive < Data | ||
attr_accessor :response, :api, :id, :sequence, :start_reason, :end_reason, :play_count, :duration, :first_downs, :gain, :penalty_yards, :scoring_drive, :quarter, :team | ||
|
||
def self.new(data, **opts) | ||
if data['type'] == 'event' | ||
Event.new(data, **opts) | ||
else | ||
super | ||
end | ||
end | ||
|
||
def initialize(data, **opts) | ||
@response = data | ||
@id = data["id"] | ||
@api = opts[:api] | ||
@plays_hash = {} | ||
@events_hash = {} | ||
|
||
update(data, **opts) | ||
end | ||
|
||
def update(data, **opts) | ||
@type = data['type'] | ||
@sequence = data["sequence"] | ||
@start_reason = data["start_reason"] | ||
@end_reason = data["end_reason"] | ||
@play_count = data["play_count"] | ||
@duration = data["duration"] | ||
@first_downs = data["first_downs"] | ||
@gain = data["gain"] | ||
@penalty_yards = data["penalty_yards"] | ||
@scoring_drive = data["scoring_drive"] | ||
|
||
@quarter_data = data['quarter'] | ||
@team_data = data['team'] | ||
|
||
create_data(@plays_hash, data['plays'], klass: Play, api: api, game: self) if data['plays'] | ||
create_data(@events_hash, data['events'], klass: Event, api: api, game: self) if data['events'] | ||
|
||
self | ||
end | ||
|
||
def plays | ||
@plays_hash.values | ||
end | ||
|
||
def events | ||
@events_hash.values | ||
end | ||
|
||
def end_reason_possibilities | ||
[ | ||
'UNKNOWN', | ||
'Touchdown', | ||
'Safety', | ||
'Field Goal', | ||
'Missed FG', | ||
'Blocked FG', | ||
'Blocked FG, Downs', | ||
'Blocked FG, Safety', | ||
'Punt', | ||
'Blocked Punt', | ||
'Blocked Punt, Downs', | ||
'Blocked Punt, Safety', | ||
'Downs', | ||
'Interception', | ||
'Fumble', | ||
'Fumble, Safety', | ||
'Muffed FG', | ||
'Muffed Punt', | ||
'Muffed Kickoff', | ||
'Kickoff', | ||
'Own Kickoff', | ||
'Onside Kick', | ||
'Kickoff, No Play', | ||
'End of Half', | ||
'End of Game', | ||
] | ||
end | ||
def normalized_end_reason | ||
case end_reason | ||
when 'Touchdown' | ||
'Touchdown' | ||
when 'Field Goal', 'Missed FG', "Blocked FG, Downs", 'Muffed FG', 'Blocked FG, Safety' | ||
'Field Goal' | ||
when 'Downs' | ||
'Downs' | ||
when 'Interception', 'Fumble' | ||
'Turnover' | ||
when 'Punt' | ||
'Punt' | ||
else | ||
'Other' | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Sportradar | ||
module Api | ||
module Football | ||
class Event < Data | ||
attr_accessor :response, :id, :sequence, :reference, :clock, :type, :event_type, :description, :alt_description | ||
|
||
def initialize(data, **opts) | ||
@response = data | ||
@id = data["id"] | ||
update(data, **opts) | ||
end | ||
def update(data, **opts) | ||
@sequence = data["sequence"] | ||
@reference = data["reference"] | ||
@clock = data["clock"] | ||
@type = data["type"] | ||
@event_type = data["event_type"] | ||
@description = data["description"] || data["summary"] | ||
@alt_description = data["alt_description"] | ||
|
||
self | ||
end | ||
def plays | ||
[] | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
Oops, something went wrong.