Class: Sportradar::Api::Baseball::Game

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/baseball/game.rb

Constant Summary collapse

DEFAULT_BASES =
{ '1' => nil, '2' => nil, '3' => nil }

Instance Attribute Summary collapse

Instance Method Summary collapse

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.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sportradar/api/baseball/game.rb', line 11

def initialize(data, **opts)
  @response = data
  @api      = opts[:api]
  # @season   = opts[:season]
  @updates  = {}
  @changes  = {}

  @score          = {}
  @team_stats     = {}
  @player_stats   = {}
  @scoring_raw    = Scoring.new(data, game: self)
  @lineup         = Lineup.new(data, game: self)
  @teams_hash     = {}
  @innings_hash   = {}
  @home_runs      = nil
  @away_runs      = nil
  @home_id        = nil
  @away_id        = nil
  @outcome        = Outcome.new(data, game: self)
  @count          = {}
  @pitchers       = {}
  @bases          = { '1' => nil, '2' => nil, '3' => nil }

  @id = data['id']

  update(data, **opts)
end

Instance Attribute Details

#attendanceObject

Returns the value of attribute attendance.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def attendance
  @attendance
end

#away_idObject

Returns the value of attribute away_id.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def away_id
  @away_id
end

#basesObject (readonly)

Returns the value of attribute bases.



7
8
9
# File 'lib/sportradar/api/baseball/game.rb', line 7

def bases
  @bases
end

#broadcastObject

Returns the value of attribute broadcast.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def broadcast
  @broadcast
end

#changesObject

Returns the value of attribute changes.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def changes
  @changes
end

#countObject (readonly)

Returns the value of attribute count.



8
9
10
# File 'lib/sportradar/api/baseball/game.rb', line 8

def count
  @count
end

#coverageObject

Returns the value of attribute coverage.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def coverage
  @coverage
end

#durationObject

Returns the value of attribute duration.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def duration
  @duration
end

#finalObject (readonly)

Returns the value of attribute final.



7
8
9
# File 'lib/sportradar/api/baseball/game.rb', line 7

def final
  @final
end

#halfObject (readonly)

Returns the value of attribute half.



7
8
9
# File 'lib/sportradar/api/baseball/game.rb', line 7

def half
  @half
end

#home_idObject

Returns the value of attribute home_id.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def home_id
  @home_id
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def id
  @id
end

#inningObject (readonly)

Returns the value of attribute inning.



7
8
9
# File 'lib/sportradar/api/baseball/game.rb', line 7

def inning
  @inning
end

#inning_overObject (readonly)

Returns the value of attribute inning_over.



7
8
9
# File 'lib/sportradar/api/baseball/game.rb', line 7

def inning_over
  @inning_over
end

#lineupObject

Returns the value of attribute lineup.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def lineup
  @lineup
end

#outcomeObject (readonly)

Returns the value of attribute outcome.



8
9
10
# File 'lib/sportradar/api/baseball/game.rb', line 8

def outcome
  @outcome
end

#outsObject (readonly)

Returns the value of attribute outs.



7
8
9
# File 'lib/sportradar/api/baseball/game.rb', line 7

def outs
  @outs
end

#pitchersObject (readonly)

Returns the value of attribute pitchers.



7
8
9
# File 'lib/sportradar/api/baseball/game.rb', line 7

def pitchers
  @pitchers
end

#player_statsObject

Returns the value of attribute player_stats.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def player_stats
  @player_stats
end

#rescheduledObject (readonly)

Returns the value of attribute rescheduled.



7
8
9
# File 'lib/sportradar/api/baseball/game.rb', line 7

def rescheduled
  @rescheduled
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def response
  @response
end

#scheduledObject

Returns the value of attribute scheduled.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def scheduled
  @scheduled
end

#scoreObject

Returns the value of attribute score.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def score
  @score
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def status
  @status
end

#team_statsObject

Returns the value of attribute team_stats.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def team_stats
  @team_stats
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def title
  @title
end

#venueObject

Returns the value of attribute venue.



5
6
7
# File 'lib/sportradar/api/baseball/game.rb', line 5

def venue
  @venue
end

Instance Method Details

#advance_inningObject



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/sportradar/api/baseball/game.rb', line 169

def advance_inning
  @inning_over = false
  return unless count['outs'] == 3
  if count['inning'] >= 9
    if count['inning_half'] == 'T' && leading_team_id == home.id
      return
    elsif count['inning_half'] == 'B' && !tied?
      return
    end
  end
  @inning_over = true
  @bases = DEFAULT_BASES.dup
  half, inn = if count['inning_half'] == 'B'
    ['E', count['inning']]
  elsif count['inning_half'] == 'T'
    ['M', count['inning']]
  else
    [nil, 1]
  end
  @count = {
    'balls'       => 0,
    'strikes'     => 0,
    'outs'        => 0,
    'inning'      => inn,
    'inning_half' => half,
  }
end

#apiObject



471
472
473
# File 'lib/sportradar/api/baseball/game.rb', line 471

def api
  @api ||= Sportradar::Api::Baseball::Mlb::Api.new
end

#assign_away(team) ⇒ Object



234
235
236
237
# File 'lib/sportradar/api/baseball/game.rb', line 234

def assign_away(team)
  @away_id = team.id
  @teams_hash[team.id] = team
end

#assign_home(team) ⇒ Object



229
230
231
232
# File 'lib/sportradar/api/baseball/game.rb', line 229

def assign_home(team)
  @home_id = team.id
  @teams_hash[team.id] = team
end

#at_batsObject



254
255
256
# File 'lib/sportradar/api/baseball/game.rb', line 254

def at_bats
  events.map(&:at_bat).compact
end

#awayObject



212
213
214
# File 'lib/sportradar/api/baseball/game.rb', line 212

def away
  @teams_hash[@away_id] || @away
end

#boxObject



239
240
241
# File 'lib/sportradar/api/baseball/game.rb', line 239

def box
  @box ||= get_box
end

#cancelled?Boolean

Returns:

  • (Boolean)


361
362
363
# File 'lib/sportradar/api/baseball/game.rb', line 361

def cancelled?
  ['unnecessary', 'postponed'].include? status
end

#changed?(key) ⇒ Boolean

Returns:

  • (Boolean)


282
283
284
# File 'lib/sportradar/api/baseball/game.rb', line 282

def changed?(key)
  @changes[key]
end

#check_newness(key, new_object) ⇒ Object



286
287
288
289
# File 'lib/sportradar/api/baseball/game.rb', line 286

def check_newness(key, new_object)
  @changes[key] = !not_updated?(key, new_object)
  remember(key, new_object)
end

#closed?Boolean

Returns:

  • (Boolean)


385
386
387
# File 'lib/sportradar/api/baseball/game.rb', line 385

def closed?
  'closed' == status
end

#completed?Boolean

Returns:

  • (Boolean)


381
382
383
# File 'lib/sportradar/api/baseball/game.rb', line 381

def completed?
  'complete' == status
end

#delayed?Boolean

Returns:

  • (Boolean)


365
366
367
# File 'lib/sportradar/api/baseball/game.rb', line 365

def delayed?
  ['wdelay', 'delayed'].include? status
end

#errors(team_id) ⇒ Object



55
56
57
# File 'lib/sportradar/api/baseball/game.rb', line 55

def errors(team_id)
  @scoring_raw.errors(team_id)
end

#eventsObject



250
251
252
# File 'lib/sportradar/api/baseball/game.rb', line 250

def events
  innings.flat_map(&:events)
end

#extract_count(data) ⇒ Object

extract from pbp



197
198
199
200
201
202
203
204
205
206
# File 'lib/sportradar/api/baseball/game.rb', line 197

def extract_count(data) # extract from pbp
  recent_pitches = pitches.last(10)
  last_pitch = recent_pitches.reverse_each.detect(&:count)
  return unless last_pitch
  update_bases(last_pitch)
  @count.merge!(last_pitch.count)
  hi = last_pitch.at_bat.event.half_inning
  @count.merge!('inning' => hi.number.to_i, 'inning_half' => hi.half)
  advance_inning
end

#finished?Boolean

Returns:

  • (Boolean)


377
378
379
# File 'lib/sportradar/api/baseball/game.rb', line 377

def finished?
  ['complete', 'closed'].include? status
end

#future?Boolean

Returns:

  • (Boolean)


369
370
371
# File 'lib/sportradar/api/baseball/game.rb', line 369

def future?
  ['scheduled', 'delayed', 'created', 'time-tbd'].include? status
end

#get_boxObject

data retrieval



408
409
410
411
# File 'lib/sportradar/api/baseball/game.rb', line 408

def get_box
  data = api.get_data(path_box)
  ingest_box(data)
end

#get_pbpObject



425
426
427
428
# File 'lib/sportradar/api/baseball/game.rb', line 425

def get_pbp
  data = api.get_data(path_pbp);
  ingest_pbp(data)
end

#get_summaryObject



447
448
449
450
# File 'lib/sportradar/api/baseball/game.rb', line 447

def get_summary
  data = api.get_data(path_summary)
  ingest_summary(data)
end

#half_inningsObject



269
270
271
# File 'lib/sportradar/api/baseball/game.rb', line 269

def half_innings
  innings.flat_map(&:half_innings)
end

#half_shortObject



344
345
346
347
348
349
350
351
# File 'lib/sportradar/api/baseball/game.rb', line 344

def half_short
  {
    'B' => 'Bot',
    'T' => 'Top',
    'M' => 'Mid',
    'E' => 'End',
  }.freeze[self.count['inning_half']]
end

#half_wordObject



335
336
337
338
339
340
341
342
# File 'lib/sportradar/api/baseball/game.rb', line 335

def half_word
  {
    'B' => 'Bottom',
    'T' => 'Top',
    'M' => 'Middle',
    'E' => 'End',
  }.freeze[self.count['inning_half']]
end

#hits(team_id) ⇒ Object

def runs(team_id)

summary_stat(team_id, 'runs')

end



52
53
54
# File 'lib/sportradar/api/baseball/game.rb', line 52

def hits(team_id)
  @scoring_raw.hits(team_id)
end

#homeObject



208
209
210
# File 'lib/sportradar/api/baseball/game.rb', line 208

def home
  @teams_hash[@home_id] || @home
end

#ingest_box(data) ⇒ Object



413
414
415
416
417
418
# File 'lib/sportradar/api/baseball/game.rb', line 413

def ingest_box(data)
  data = data['game']
  update(data, source: :box)
  check_newness(:box, @clock)
  data
end

#ingest_pbp(data) ⇒ Object



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/sportradar/api/baseball/game.rb', line 430

def ingest_pbp(data)
  data = data['game']
  update(data, source: :pbp)
  innings = data['innings'].each { |inning| inning['id'] = "#{data['id']}-#{inning['number']}" }
  create_data(@innings_hash, innings, klass: Inning, api: api, game: self) if data['innings']
  extract_count(data)
  lineup.update(data, source: :pbp)
  # update lineups
  check_newness(:pitches, pitches.last&.id)
  check_newness(:events, events.last&.description)
  check_newness(:score, @score)
  @pbp = @innings_hash.values
  data
# rescue => e
#   binding.pry
end

#ingest_summary(data) ⇒ Object



457
458
459
460
461
462
463
464
# File 'lib/sportradar/api/baseball/game.rb', line 457

def ingest_summary(data)
  data = data['game']
  update(data, source: :summary)
  @inning = data.delete('inning').to_i
  check_newness(:box, @clock)
  check_newness(:score, @score)
  data
end

#inning_abbrObject



307
308
309
310
311
312
313
# File 'lib/sportradar/api/baseball/game.rb', line 307

def inning_abbr
  if !count.empty?
    inning_half = self.count['inning_half']
    inning = self.count['inning']
    "#{inning_half || 'T'}#{(inning || 1)}"
  end
end

#inning_shortObject



315
316
317
318
319
320
321
# File 'lib/sportradar/api/baseball/game.rb', line 315

def inning_short
  if !count.empty?
    inning_half = self.count['inning_half']
    inning = self.count['inning']
    "#{half_short} #{ordinalize_inning(inning || 1)}" # TODO remove AS dependency
  end
end

#inning_wordObject



323
324
325
326
327
328
329
# File 'lib/sportradar/api/baseball/game.rb', line 323

def inning_word
  if !count.empty?
    inning_half = self.count['inning_half']
    inning = self.count['inning']
    "#{half_word} #{ordinalize_inning(inning || 1)}"
  end
end

#inningsObject



266
267
268
# File 'lib/sportradar/api/baseball/game.rb', line 266

def innings
  @innings_hash.values
end

#leading_teamObject



221
222
223
# File 'lib/sportradar/api/baseball/game.rb', line 221

def leading_team
  @teams_hash[leading_team_id] || (@away_id == leading_team_id && away) || (@home_id == leading_team_id && home)
end

#leading_team_idObject



216
217
218
219
# File 'lib/sportradar/api/baseball/game.rb', line 216

def leading_team_id
  return nil if tied?
  score.max_by(&:last).first
end

#not_updated?(key, object) ⇒ Boolean

Returns:

  • (Boolean)


278
279
280
# File 'lib/sportradar/api/baseball/game.rb', line 278

def not_updated?(key, object)
  @updates[key] == object
end

#ordinalize_inning(i) ⇒ Object



331
332
333
# File 'lib/sportradar/api/baseball/game.rb', line 331

def ordinalize_inning(i)
  Sportradar.ordinalize_period(i)
end

#parse_pitchers(data) ⇒ Object



94
95
96
97
98
99
100
101
102
103
# File 'lib/sportradar/api/baseball/game.rb', line 94

def parse_pitchers(data)
  pitchers = {
    'starting'  => { home_id => data.dig('home', 'starting_pitcher'), away_id => data.dig('away', 'starting_pitcher')},
    'probable'  => { home_id => data.dig('home', 'probable_pitcher'), away_id => data.dig('away', 'probable_pitcher')},
    'current'   => { home_id => data.dig('home', 'current_pitcher'),  away_id => data.dig('away', 'current_pitcher')},
  }
  @pitchers.merge!(pitchers) do |key, current_val, merge_val|
    current_val.merge(merge_val) { |k, cur, mer| (mer || cur) }
  end
end

#parse_score(data) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/sportradar/api/baseball/game.rb', line 81

def parse_score(data)
  home_id = data.dig('home', 'id')
  away_id = data.dig('away', 'id')
  rhe = {
    'runs'    => { home_id => data.dig('home', 'runs'), away_id => data.dig('away', 'runs')},
    'hits'    => { home_id => data.dig('home', 'hits'), away_id => data.dig('away', 'hits')},
    'errors'  => { home_id => data.dig('home', 'errors'), away_id => data.dig('away', 'errors')},
  }
  @scoring_raw.update(rhe, source: :rhe)
  update_score(home_id => data.dig('home', 'runs'))
  update_score(away_id => data.dig('away', 'runs'))
end

#path_baseObject

url path helpers



390
391
392
# File 'lib/sportradar/api/baseball/game.rb', line 390

def path_base
  "games/#{ id }"
end

#path_boxObject



394
395
396
# File 'lib/sportradar/api/baseball/game.rb', line 394

def path_box
  "#{ path_base }/boxscore"
end

#path_pbpObject



398
399
400
# File 'lib/sportradar/api/baseball/game.rb', line 398

def path_pbp
  "#{ path_base }/pbp"
end

#path_summaryObject



402
403
404
# File 'lib/sportradar/api/baseball/game.rb', line 402

def path_summary
  "#{ path_base }/summary"
end

#pbpObject



243
244
245
246
247
248
# File 'lib/sportradar/api/baseball/game.rb', line 243

def pbp
  if !future? && innings.empty?
    get_pbp
  end
  @pbp ||= innings
end

#pitchesObject



258
259
260
# File 'lib/sportradar/api/baseball/game.rb', line 258

def pitches
  at_bats.flat_map(&:pitches)
end

#postponed?Boolean

Returns:

  • (Boolean)


353
354
355
# File 'lib/sportradar/api/baseball/game.rb', line 353

def postponed?
  'postponed' == status
end

#queue_pbpObject



420
421
422
423
# File 'lib/sportradar/api/baseball/game.rb', line 420

def queue_pbp
  url, headers, options, timeout = api.get_request_info(path_pbp)
  {url: url, headers: headers, params: options, timeout: timeout, callback: method(:ingest_pbp)}
end

#queue_summaryObject



452
453
454
455
# File 'lib/sportradar/api/baseball/game.rb', line 452

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

#realtime_state(full_word: false) ⇒ Object

status helpers



293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/sportradar/api/baseball/game.rb', line 293

def realtime_state(full_word: false)
  if future?
    'Scheduled'
  elsif delayed?
    'Delayed'
  elsif finished?
    'Final'
  elsif postponed?
    'Postponed'
  else
    full_word ? inning_word : inning_short
  end
end

#remember(key, object) ⇒ Object

tracking updates



274
275
276
# File 'lib/sportradar/api/baseball/game.rb', line 274

def remember(key, object)
  @updates[key] = object&.dup
end

#runs(team_id) ⇒ Object



58
59
60
# File 'lib/sportradar/api/baseball/game.rb', line 58

def runs(team_id)
  team_id.is_a?(Symbol) ? @score[@team_ids[team_id]] : @score[team_id]
end

#scoringObject



68
69
70
# File 'lib/sportradar/api/baseball/game.rb', line 68

def scoring
  @scoring_raw.scores
end

#set_pbp(data) ⇒ Object



466
467
468
469
# File 'lib/sportradar/api/baseball/game.rb', line 466

def set_pbp(data)
  create_data(@innings_hash, data, klass: inning_class, api: api, game: self)
  @innings_hash
end

#sim!Object



475
476
477
478
# File 'lib/sportradar/api/baseball/game.rb', line 475

def sim!
  @api = api.sim!
  self
end

#started?Boolean

Returns:

  • (Boolean)


373
374
375
# File 'lib/sportradar/api/baseball/game.rb', line 373

def started?
  ['inprogress', 'wdelay', 'delayed'].include? status
end

#stats(team_id) ⇒ Object



64
65
66
# File 'lib/sportradar/api/baseball/game.rb', line 64

def stats(team_id)
  team_id.is_a?(Symbol) ? @team_stats[@team_ids[team_id]].to_i : @team_stats[team_id].to_i
end

#summaryObject



262
263
264
# File 'lib/sportradar/api/baseball/game.rb', line 262

def summary
  @summary ||= get_summary
end

#summary_stat(team_id, stat_name) ⇒ Object



61
62
63
# File 'lib/sportradar/api/baseball/game.rb', line 61

def summary_stat(team_id, stat_name)
  scoring.dig(team_id, stat_name)
end

#team(team_id) ⇒ Object



225
226
227
# File 'lib/sportradar/api/baseball/game.rb', line 225

def team(team_id)
  @teams_hash[team_id]
end

#tied?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/sportradar/api/baseball/game.rb', line 46

def tied?
  @score[away_id].to_i == @score[home_id].to_i
end

#timeoutsObject



42
43
44
# File 'lib/sportradar/api/baseball/game.rb', line 42

def timeouts
  {}
end

#unnecessary?Boolean

Returns:

  • (Boolean)


357
358
359
# File 'lib/sportradar/api/baseball/game.rb', line 357

def unnecessary?
  'unnecessary' == status
end

#update(data, source: nil, **opts) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/sportradar/api/baseball/game.rb', line 105

def update(data, source: nil, **opts)
  # via pbp
  @status       = data['status']                if data['status']
  @coverage     = data['coverage']              if data['coverage']
  @day_night    = data['day_night']             if data['day_night']
  @game_number  = data['game_number']           if data['game_number']
  @home_id      = data['home_team'] || data.dig('home', 'id')   if data['home_team'] || data.dig('home', 'id')
  @away_id      = data['away_team'] || data.dig('away', 'id')   if data['away_team'] || data.dig('away', 'id')
  # @home_runs    = data['home_runs'].to_i      if data['home_runs']
  # @away_runs    = data['away_runs'].to_i      if data['away_runs']

  @scheduled    = Time.parse(data["scheduled"]) if data["scheduled"]
  @venue        = Venue.new(data['venue']) if data['venue']
  @broadcast    = Broadcast.new(data['broadcast']) if !data['broadcast'].to_h.empty?
  @home         = Team.new(data['home'] || data.dig('scoring', 'home'), api: api, game: self) if data['home'] || data.dig('scoring', 'home')
  @away         = Team.new(data['away'] || data.dig('scoring', 'away'), api: api, game: self) if data['away'] || data.dig('scoring', 'away')
  @title        = data['title'] || @title || (home && away && "#{home.full_name} vs #{away.full_name}")

  @duration     = data['duration']              if data['duration']
  @attendance   = data['attendance']            if data['attendance']

  @final        = data['final']                 if data['final']
  @rescheduled  = data['rescheduled']           if data['rescheduled']

  @team_ids     = { home: @home_id, away: @away_id}

  update_bases(data)
  parse_pitchers(data) if data['home'] && data['away']

  lineup.update(data, source: source) unless source == :pbp
  if data['scoring']
    parse_score(data['scoring'])
  elsif data.dig('home', 'hits')
    parse_score(data)
  end
  @scoring_raw.update(data, source: source)
  if data['outcome']
    @outcome.update(data, source: nil)
    @count.merge!(@outcome.count || {})
  end
  create_data(@teams_hash, data['team'], klass: Team, api: api, game: self) if data['team']
end

#update_bases(data) ⇒ Object

def update_from_team(id, data) end



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/sportradar/api/baseball/game.rb', line 151

def update_bases(data)
  if data.is_a?(Sportradar::Api::Baseball::Error)
    puts data.inspect
    return
  end
  @bases = if data.respond_to?(:runners)
    hash = Array(data.runners).map { |runner| [runner.ending_base.to_s, runner.id] if !runner.out }.compact.to_h
    DEFAULT_BASES.merge(hash)
  elsif (runners = data.dig('outcome', 'runners'))
    hash = runners.map { |runner| [runner['ending_base'].to_s, runner['id']] if !runner['out'] }.compact.to_h
    DEFAULT_BASES.merge(hash)
  else # probably new inning, no runners
    DEFAULT_BASES.dup
  end
rescue => e
  puts data.inspect
  raise e
end

#update_player_stats(player, stats) ⇒ Object



77
78
79
# File 'lib/sportradar/api/baseball/game.rb', line 77

def update_player_stats(player, stats)
  @player_stats.merge!(player.id => stats.merge!(player: player))
end

#update_score(score) ⇒ Object



71
72
73
# File 'lib/sportradar/api/baseball/game.rb', line 71

def update_score(score)
  @score.merge!(score)
end

#update_stats(team, stats) ⇒ Object



74
75
76
# File 'lib/sportradar/api/baseball/game.rb', line 74

def update_stats(team, stats)
  @team_stats.merge!(team.id => stats.merge!(team: team))
end