sportradar-api 0.10.19 → 0.10.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ec989fe54a2bb5f41b7a526c44601fd8b78058a
4
- data.tar.gz: de5ba7e5a37af17b9a6813afa74e52968a234f6a
3
+ metadata.gz: 9cc02895e5d46c3ec34afff00c0d5b40f31a45bb
4
+ data.tar.gz: 5224e0148451fadae1920348947ab126ed975c4b
5
5
  SHA512:
6
- metadata.gz: 05c67e5354d3e933f3603dfccd8d8eeef55e28656de784763151c6e1085e0beda3cd34573dd9eebae763316b7cdbfbe2308559f05cfb3d572537429337414746
7
- data.tar.gz: a64e7bf052f0c6660f1d0796c7dc342c76975b6e0225b05e0918deba6943593775a77e1855be7b97f3c6ca59ed685ebdea071f47a3f01582fe5e1bf77aac0f0f
6
+ metadata.gz: 4548b6f36e75c79ea25638bec02c0e06d5a2c595de299353fd6a1895e95c36ae9391325c3b9dc2c65d1daaa8ee6aef048c4cdad75ef0fbeb4e0fc04f7bd2fd47
7
+ data.tar.gz: 1951e3129195646a964d5f7fa10f4818875aa08e531758714256c8483b420edad218c46e4344b530353e946bc7da85b1e7dba212c03445f6c0cad15b96c00889
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportradar-api (0.10.19)
4
+ sportradar-api (0.10.20)
5
5
  activesupport
6
6
  httparty (>= 0.14.0)
7
7
 
@@ -6,6 +6,7 @@ module Sportradar
6
6
 
7
7
  attr_reader :inning, :half, :outs, :bases, :pitchers
8
8
  attr_reader :outcome, :count
9
+ DEFAULT_BASES = { '1' => nil, '2' => nil, '3' => nil }
9
10
 
10
11
  def initialize(data, **opts)
11
12
  @response = data
@@ -27,6 +28,7 @@ module Sportradar
27
28
  @outcome = Outcome.new(data, game: self)
28
29
  @count = {}
29
30
  @pitchers = {}
31
+ @bases = { '1' => nil, '2' => nil, '3' => nil }
30
32
 
31
33
  @id = data['id']
32
34
 
@@ -119,6 +121,7 @@ module Sportradar
119
121
 
120
122
  @team_ids = { home: @home_id, away: @away_id}
121
123
 
124
+ update_bases(data)
122
125
  parse_pitchers(data) if data['home'] && data['away']
123
126
 
124
127
  if data['scoring']
@@ -138,10 +141,23 @@ module Sportradar
138
141
  # def update_from_team(id, data)
139
142
  # end
140
143
 
144
+ def update_bases(data)
145
+ @bases = if data.respond_to?(:runners)
146
+ hash = data.runners.map { |runner| [runner.ending_base.to_s, runner.id] if !runner.out }.to_h
147
+ DEFAULT_BASES.merge(hash)
148
+ elsif (runners = data.dig('outcome', 'runners'))
149
+ hash = runners.map { |runner| [runner['ending_base'].to_s, runner['id']] if !runner['out'] }.to_h
150
+ DEFAULT_BASES.merge(hash)
151
+ else # probably new inning, no runners
152
+ DEFAULT_BASES.dup
153
+ end
154
+ end
155
+
141
156
  def extract_count(data) # extract from pbp
142
157
  recent_pitches = pitches.last(10)
143
158
  last_pitch = recent_pitches.reverse_each.detect(&:count)
144
159
  return unless last_pitch
160
+ update_bases(last_pitch)
145
161
  @count.merge!(last_pitch.count)
146
162
  hi = last_pitch.at_bat.event.half_inning
147
163
  @count.merge!('inning' => hi.number.to_i, 'inning_half' => hi.half)
@@ -2,7 +2,7 @@ module Sportradar
2
2
  module Api
3
3
  module Baseball
4
4
  class Pitch < Data
5
- attr_accessor :response, :id, :at_bat, :outcome_id, :status, :count, :is_ab_over, :warming_up
5
+ attr_accessor :response, :id, :at_bat, :outcome_id, :status, :count, :is_ab_over, :warming_up, :runners
6
6
 
7
7
  def initialize(data, **opts)
8
8
  @response = data
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.10.19"
3
+ VERSION = "0.10.20"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportradar-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.19
4
+ version: 0.10.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-09 00:00:00.000000000 Z
11
+ date: 2017-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler