Class: Sportradar::Api::Football::Ncaafb::Game

Inherits:
Game
  • Object
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

#apiObject



109
110
111
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 109

def api
  @api ||= Sportradar::Api::Football::Ncaafb::Api.new
end

#clock_displayObject



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

#drive_classObject



105
106
107
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 105

def drive_class
  Sportradar::Api::Football::Ncaafb::Drive
end

#generate_titleObject



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_boxObject



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_summaryObject



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

Returns:

  • (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_baseObject



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_classObject



93
94
95
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 93

def period_class
  Quarter
end

#period_nameObject



97
98
99
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 97

def period_name
  'quarter'
end

#quarter_classObject



101
102
103
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 101

def quarter_class
  Sportradar::Api::Football::Ncaafb::Quarter
end

#queue_extended_boxObject



50
51
52
53
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 50

def queue_extended_box
  url, headers, options, timeout = api.get_request_info(path_extended_box)
  {url: url, headers: headers, params: options, timeout: timeout, callback: method(:ingest_extended_box)}
end

#queue_summaryObject



67
68
69
70
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 67

def queue_summary
  url, headers, options, timeout = api.get_request_info(path_summary)
  {url: url, headers: headers, params: options, timeout: timeout, callback: method(:ingest_summary)}
end

#team_classObject



90
91
92
# File 'lib/sportradar/api/football/ncaafb/game.rb', line 90

def team_class
  Team
end

#typeObject

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 # Bowl games don't seem to work when they use the bowl type instead of REG
  'REG'
end