sportradar 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2625e9b8c98a1e5793714d15517dd04f0ad37efc
4
- data.tar.gz: 0a97125cceba86de1c4d0631b4835cd2ffa30cf5
3
+ metadata.gz: b42d43b15fbe12d48b0f3918be5b2c2db11bc503
4
+ data.tar.gz: 809492516e7a194cbe7669301ee93b0d8f90ae04
5
5
  SHA512:
6
- metadata.gz: 9922e5f9f7b166e966daee70d70463ce55698105f9b84139d712b4a72c2d2271b9584ac30dcb42a58efdf07d175ea6c2b5592b7c7fdac03d04039a8fefb20dff
7
- data.tar.gz: e386fe7a0545a0518c0e1c5265b3c2bb0c3b9425417f5e0908fffc400b1b0767a1883204a41fb87fdc771642d54845112a75204435e487b394266b4a80489491
6
+ metadata.gz: 4583f7e8b73bbf324785f80de0d18512b31ade086a393579fbf55d6d98b7354948bace4968006071804ef0722ec4981530da54bafafe09bb30b9714ff7605a5a
7
+ data.tar.gz: 3bce027092efa73b7002510a4a648574e1776c79a4f928b5635244e0a39adb60f05861816a53ae34facddfb7959b986761803d00527590a0a3b895f7e8d67f44
data/README.md CHANGED
@@ -14,7 +14,7 @@ Currently supports
14
14
  Add this line to your application's Gemfile:
15
15
 
16
16
  ```ruby
17
- gem 'sportradar', '>= 0.0.18'
17
+ gem 'sportradar', '>= 0.0.20'
18
18
  ```
19
19
 
20
20
  And then execute:
@@ -2,6 +2,10 @@ module Sportradar
2
2
  module Nba
3
3
  module Models
4
4
  class Event
5
+ COURT_LENGTH = 1128
6
+ BASKET_CENTER_X = 57
7
+ BASKET_CENTER_Y = 300
8
+
5
9
  def initialize(quarter:, attributes:)
6
10
  @quarter = quarter
7
11
  @attributes = attributes
@@ -20,6 +24,8 @@ module Sportradar
20
24
  sentence_parts << free_throw_attempt_of
21
25
  sentence_parts << turnover_type
22
26
  sentence_parts << "[#{coordinate_x}, #{coordinate_y}]" if coordinates?
27
+ sentence_parts << distance_from_scoring_basket_inches
28
+ sentence_parts << distance_to_scoring_basket_inches
23
29
  end.compact.
24
30
  join(' - ')
25
31
  end
@@ -142,6 +148,42 @@ module Sportradar
142
148
  @attributes['description'] || 0
143
149
  end
144
150
 
151
+ def distance_from_scoring_basket_inches
152
+ if coordinates?
153
+ if scoring_basket = team_basket
154
+ if scoring_basket == 'left'
155
+ Math.hypot(COURT_LENGTH - coordinate_x - BASKET_CENTER_X,
156
+ (coordinate_y - BASKET_CENTER_Y).abs).
157
+ round(3)
158
+ elsif scoring_basket == 'right'
159
+ Math.hypot(coordinate_x - BASKET_CENTER_X,
160
+ (coordinate_y - BASKET_CENTER_Y).abs).
161
+ round(3)
162
+ else
163
+ 0
164
+ end
165
+ end
166
+ end
167
+ end
168
+
169
+ def distance_to_scoring_basket_inches
170
+ if coordinates?
171
+ if scoring_basket = team_basket
172
+ if scoring_basket == 'left'
173
+ Math.hypot(coordinate_x - BASKET_CENTER_X,
174
+ (coordinate_y - BASKET_CENTER_Y).abs).
175
+ round(3)
176
+ elsif scoring_basket == 'right'
177
+ Math.hypot(COURT_LENGTH - coordinate_x - BASKET_CENTER_X,
178
+ (coordinate_y - BASKET_CENTER_Y).abs).
179
+ round(3)
180
+ else
181
+ 0
182
+ end
183
+ end
184
+ end
185
+ end
186
+
145
187
  def event_type
146
188
  @attributes['event_type']
147
189
  end
@@ -152,11 +152,11 @@ module Sportradar
152
152
  scoring_data['points'].to_i
153
153
  overtime_points += scoring_data['points'].to_i
154
154
  scoring_periods[:goals_overtime] = overtime_points
155
+ elsif period_type == 'shootout'
156
+ key = "goals_#{period_type}".to_sym
157
+ scoring_periods[key] =
158
+ scoring_data['points'].to_i
155
159
  end
156
- elsif period_type == 'shootout'
157
- key = "goals_#{period_type}".to_sym
158
- scoring_periods[key] =
159
- scoring_data['points'].to_i
160
160
  end
161
161
  end
162
162
  end
@@ -1,3 +1,3 @@
1
1
  module Sportradar
2
- VERSION = '0.0.19'
2
+ VERSION = '0.0.20'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportradar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stattleship
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-10-18 00:00:00.000000000 Z
12
+ date: 2016-10-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler