sportradar-api 0.1.26 → 0.1.27

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: a8152d88570a153230df0842c30f947da8afbbe2
4
- data.tar.gz: b38e08d450f80f5c68f6b8474ec95163b1e526f7
3
+ metadata.gz: 780721e94bb01f11aeec1d1403e40089f95e992a
4
+ data.tar.gz: 3b9c68f4b8573f70ba7147a96c9d87122d154206
5
5
  SHA512:
6
- metadata.gz: c3e59f66dc5d98d494873fd122b75bed923804d423f94060c443be228f02efe93d3e07ea5c867a7d948b2df254967925274a0211a962e2bde4373e452e1bd1cb
7
- data.tar.gz: f316981383a33e70238c1d48c27f50fd0c907a2148aaff2891073a4ef308391acfbb4412a0837873df74d88b6c65f190b50b1d0f79e68cb32d9bdd26186f5f04
6
+ metadata.gz: 7085b9b72a97c9aa466213d760ee79bf5790517d346e629a1f0868d6357f1d561a36e3c71b9e6007f1b30faff797d2a73c1f40b246b62c0db89b0f63448955ea
7
+ data.tar.gz: fc17aa495f9e2d8573b4af50358f7b277ea3d3651ae9330e6e3cf99a373092db2cb3470930e290ccf9635eaa18cca3ca3dd71c564fdbe24198aaa09e17f258ba
@@ -26,9 +26,10 @@ module Sportradar
26
26
  @scoring = Sportradar::Api::Nfl::Scoring.new data["scoring"] if data["scoring"]
27
27
  set_scoring_drives
28
28
 
29
- @venue = Sportradar::Api::Nfl::Venue.new data["venue"] if data["venue"]
30
- @home = Sportradar::Api::Nfl::Team.new data["home"] if data["home"]
31
- @away = Sportradar::Api::Nfl::Team.new data["away"] if data["away"]
29
+ location = data["summary"] || data
30
+ @venue = Sportradar::Api::Nfl::Venue.new location["venue"] if location["venue"]
31
+ @home = Sportradar::Api::Nfl::Team.new location["home"] if location["home"]
32
+ @away = Sportradar::Api::Nfl::Team.new location["away"] if location["away"]
32
33
  @broadcast = Sportradar::Api::Nfl::Broadcast.new data["broadcast"] if data["broadcast"]
33
34
  end
34
35
 
@@ -1,7 +1,7 @@
1
1
  module Sportradar
2
2
  module Api
3
3
  class Nfl::Season < Data
4
- attr_accessor :response, :id, :year, :type, :name, :weeks, :injuries, :team, :conferences
4
+ attr_accessor :response, :id, :year, :type, :name, :weeks, :injuries, :team, :conferences, :divisions, :teams
5
5
 
6
6
  def initialize(data)
7
7
  @response = data
@@ -13,6 +13,8 @@ module Sportradar
13
13
  @injuries = data["injuries"]["team"].map {|team| Sportradar::Api::Nfl::Team.new team } if data["injuries"] && data["injuries"]["team"]
14
14
  set_weeks
15
15
  set_conferences
16
+ set_divisions
17
+ set_teams
16
18
  end
17
19
 
18
20
  private
@@ -27,6 +29,9 @@ module Sportradar
27
29
  end
28
30
  end
29
31
 
32
+ # set_(conferences|divisions|teams) are all identical to the same methods in Hierarchy
33
+ # There is likely more overlap between Sportradar's NFL standings and NFL hierarchy APIs
34
+ # Eventually, these should be shared between classes
30
35
  def set_conferences
31
36
  if response["conference"]
32
37
  if response["conference"].is_a?(Array)
@@ -37,6 +42,22 @@ module Sportradar
37
42
  end
38
43
  end
39
44
 
45
+ def set_divisions
46
+ if conferences&.all? { |conference| conference.divisions }
47
+ @divisions = conferences.flat_map(&:divisions)
48
+ elsif response["division"]
49
+ if response["division"].is_a?(Array)
50
+ @divisions = response["division"].map {|division| Sportradar::Api::Nfl::Division.new division }
51
+ elsif response["division"].is_a?(Hash)
52
+ @divisions = [ Sportradar::Api::Nfl::Division.new(response["division"]) ]
53
+ end
54
+ end
55
+ end
56
+
57
+ def set_teams
58
+ @teams = @divisions.flat_map(&:teams) if divisions&.all? {|division| division.teams }
59
+ end
60
+
40
61
  end
41
62
  end
42
63
  end
@@ -1,8 +1,7 @@
1
1
  module Sportradar
2
2
  module Api
3
3
  class Nfl::Team < Data
4
- attr_accessor :response, :id, :name, :alias, :game_number, :defense, :special_teams, :offense, :players, :statistics, :team_records, :player_records, :market, :franchise, :venue, :hierarchy, :coaches, :players, :used_timeouts, :remaining_timeouts, :points
5
-
4
+ attr_accessor :response, :id, :name, :alias, :game_number, :defense, :special_teams, :offense, :players, :statistics, :team_records, :player_records, :market, :franchise, :venue, :hierarchy, :coaches, :players, :used_timeouts, :remaining_timeouts, :points, :wins, :losses, :ties, :win_pct, :rank
6
5
 
7
6
  def initialize(data)
8
7
  @response = data
@@ -21,6 +20,13 @@ module Sportradar
21
20
  @venue = Sportradar::Api::Nfl::Venue.new data["venue"] if data["venue"]
22
21
  @hierarchy = Sportradar::Api::Nfl::Hierarchy.new data["hierarchy"] if data["hierarchy"]
23
22
 
23
+ @wins = data["wins"]
24
+ @losses = data["losses"]
25
+ @losses = data["losses"]
26
+ @ties = data["ties"]
27
+ @win_pct = data["win_pct"].to_f if data["win_pct"]
28
+ @rank = data["rank"]
29
+
24
30
  @defense = data["defense"]["position"].map {|position| Sportradar::Api::Nfl::Position.new position } if data["defense"] && data["defense"]["position"]
25
31
  @offense = data["offense"]["position"].map {|position| Sportradar::Api::Nfl::Position.new position } if data["offense"] && data["offense"]["position"]
26
32
  @special_teams = data["special_teams"]["position"].map {|position| Sportradar::Api::Nfl::Position.new position } if data["special_teams"] && data["special_teams"]["position"]
@@ -36,6 +42,12 @@ module Sportradar
36
42
  [market, name].join(' ')
37
43
  end
38
44
 
45
+ def record
46
+ if wins && losses && ties
47
+ "#{wins}-#{losses}" << (ties == '0' ? '' : "-#{ties}")
48
+ end
49
+ end
50
+
39
51
  private
40
52
 
41
53
  def set_players
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.1.26"
3
+ VERSION = "0.1.27"
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.1.26
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-12 00:00:00.000000000 Z
11
+ date: 2016-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -307,3 +307,4 @@ signing_key:
307
307
  specification_version: 4
308
308
  summary: Sportradar API client
309
309
  test_files: []
310
+ has_rdoc: