Class: Sportradar::Api::Football::Ncaafb::Game
- Inherits:
-
Game
- Object
- Data
- Game
- Sportradar::Api::Football::Ncaafb::Game
show all
- Defined in:
- lib/sportradar/api/football/ncaafb/game.rb
Instance Attribute Summary
Attributes inherited from Game
#attendance, #away_id, #broadcast, #changes, #clock, #coverage, #duration, #home_id, #id, #lineup, #player_stats, #quarter, #response, #scheduled, #score, #status, #team_stats, #title, #venue, #week, #week_number, #year
Instance Method Summary
collapse
Methods inherited from Game
#assign_away, #assign_home, #away, #away_alias, #box, #cancelled?, #changed?, #check_newness, #closed?, #completed?, #current_possession_team_id, #delayed?, #drives, #drives_with_events, #events, #finished?, #future?, #get_box, #get_pbp, #get_statistics, #half_quarters, #home, #home_alias, #ingest_box, #ingest_statistics, #leading_team, #leading_team_id, #next_possession_team_id, #not_updated?, #parse_score, #path_box, #path_extended_box, #path_pbp, #path_roster, #path_statistics, #path_summary, #pbp, #period, #period_key, #plays, #postponed?, #quarter_display, #quarters, #queue_pbp, #queue_statistics, #realtime_state, #remember, #scoring, #sim!, #started?, #stats, #summary_stat, #team, #team_ids, #tied?, #timeouts, #unnecessary?, #update, #update_drives, #update_player_stats, #update_score, #update_stats, #update_teams
Methods inherited from Data
#all_attributes, #attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data
Constructor Details
#initialize(data, **opts) ⇒ Game
Returns a new instance of Game.
7
8
9
10
11
12
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 7
def initialize(data, **opts)
if data['id'].include?('/')
@year, @type, @week_number, @away_alias, @home_alias = data.delete('id').split('/')
end
super
end
|
Instance Method Details
#clock_display ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 18
def clock_display
if clock && quarter
if clock == ':00' && quarter == 2
'Half'
else
quarter > 4 ? quarter_display : "#{clock} #{quarter_display}"
end
end
end
|
#generate_title ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 32
def generate_title
if home.full_name && away.full_name
"#{home.full_name} vs #{away.full_name}"
elsif home_alias && away_alias
"#{home_alias} vs #{away_alias}"
end
end
|
#get_extended_box ⇒ Object
45
46
47
48
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 45
def get_extended_box
data = api.get_data(path_extended_box).to_h
ingest_extended_box(data)
end
|
#get_summary ⇒ Object
62
63
64
65
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 62
def get_summary
data = api.get_data(path_summary).to_h
ingest_summary(data)
end
|
#halftime? ⇒ Boolean
14
15
16
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 14
def halftime?
clock == ':00' && quarter == 2
end
|
#ingest_extended_box(data) ⇒ Object
55
56
57
58
59
60
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 55
def ingest_extended_box(data)
data = data
update(data, source: :extended_box)
check_newness(:extended_box, @clock)
data
end
|
#ingest_pbp(data) ⇒ Object
81
82
83
84
85
86
87
88
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 81
def ingest_pbp(data)
super.tap {
clock = self.plays.last&.clock
quarter = self.quarters.last&.number
@clock = clock if clock
@quarter = quarter if quarter
}
end
|
#ingest_summary(data) ⇒ Object
72
73
74
75
76
77
78
79
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 72
def ingest_summary(data)
data = data
update(data, source: :summary)
@quarter = data.delete('quarter').to_i
check_newness(:box, @clock)
check_newness(:score, @score)
data
end
|
#path_base ⇒ Object
28
29
30
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 28
def path_base
"#{ year }/#{ type }/#{ week_number.to_s }/#{ away_alias }/#{ home_alias }"
end
|
#period_class ⇒ Object
93
94
95
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 93
def period_class
Quarter
end
|
#period_name ⇒ Object
97
98
99
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 97
def period_name
'quarter'
end
|
#queue_extended_box ⇒ Object
50
51
52
53
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 50
def queue_extended_box
url, , options, timeout = api.get_request_info(path_extended_box)
{url: url, headers: , params: options, timeout: timeout, callback: method(:ingest_extended_box)}
end
|
#queue_summary ⇒ Object
67
68
69
70
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 67
def queue_summary
url, , options, timeout = api.get_request_info(path_summary)
{url: url, headers: , params: options, timeout: timeout, callback: method(:ingest_summary)}
end
|
#team_class ⇒ Object
90
91
92
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 90
def team_class
Team
end
|
#type ⇒ Object
Bowl games don’t seem to work when they use the bowl type instead of REG
40
41
42
|
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 40
def type 'REG'
end
|