Class: Sportradar::Api::Football::Ncaafb::Play
- Inherits:
-
Play
- Object
- Data
- Play
- Sportradar::Api::Football::Ncaafb::Play
show all
- Defined in:
- lib/sportradar/api/football/ncaafb/play.rb
Instance Attribute Summary
Attributes inherited from Play
#alt_description, #away_points, #clock, #description, #down, #end_situation, #event_type, #home_points, #id, #play_clock, #player_data, #player_id, #players, #reference, #response, #score, #scoring_play, #sequence, #start_situation, #statistics, #team_id, #type, #wall_clock, #yfd
Instance Method Summary
collapse
Methods inherited from Play
#clock_seconds, #counted_play?, #deleted?, #down_distance, #end_of_regulation?, #end_spot, #initialize, #parse_player, #parsed_ending, #search_for_drive_end, #start_spot, #timeout?, #update, #updated
Methods inherited from Data
#all_attributes, #attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data
Instance Method Details
#event? ⇒ Boolean
48
49
50
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 48
def event?
!play?
end
|
#get_details ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 72
def get_details
if @details && !has_details?
data = @api.get_data(@details).to_h
update_details(data)
data
end
end
|
#halftime? ⇒ Boolean
52
53
54
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 52
def halftime?
@description == "End of 1st Half"
end
|
#has_details? ⇒ Boolean
63
64
65
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 63
def has_details?
!@detailed_data.nil?
end
|
#made_first_down? ⇒ Boolean
23
24
25
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 23
def made_first_down?
statistics.pass&.first&.firstdown == 1 || statistics.rush&.first&.firstdown == 1
end
|
#play? ⇒ Boolean
31
32
33
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 31
def play?
@event_type.nil?
end
|
#play_type ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 7
def play_type
if @play_type.nil?
nil
elsif self.timeout?
'timeout'
elsif @play_type.casecmp? 'kick'
'kickoff'
elsif @play_type.casecmp? 'extrapoint'
'extra point'
elsif @play_type.casecmp? 'fieldgoal'
'field goal'
else
super
end
end
|
#queue_details ⇒ Object
56
57
58
59
60
61
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 56
def queue_details
if @details && !has_details?
url, , options, timeout = @api.get_request_info(@details)
{url: url, headers: , params: options, timeout: timeout, callback: method(:update_details)}
end
end
|
#scoring_play? ⇒ Boolean
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 35
def scoring_play?
case @play_type
when 'fieldgoal'
statistics.field_goal&.any?(&:made?)
when 'extrapoint'
true when 'safety'
true
else
statistics.pass&.any?(&:touchdown?) || statistics.rush&.any?(&:touchdown?)
end
end
|
#update_details(data) ⇒ Object
67
68
69
70
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 67
def update_details(data)
@detailed_data = data
update(data)
end
|
#yards ⇒ Object
27
28
29
|
# File 'lib/sportradar/api/football/ncaafb/play.rb', line 27
def yards
counted_play? ? (statistics.pass&.first || statistics.rush&.first)&.yards.to_i : 0
end
|