sportradar-api 0.1.16 → 0.1.17

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: bf5da00a357336387a9366e47e048f800e390143
4
- data.tar.gz: 31f39f3bf638e1715137dc80ca6deb491ad75f37
3
+ metadata.gz: becdba7a870fb4ee7bfc5c2b76f44af5084b5e79
4
+ data.tar.gz: f64e463d94380a738a0544d193a743978def051d
5
5
  SHA512:
6
- metadata.gz: 279bbcd1ad4253ddad805f5526309d2532ae8402fc49af18a3fb8a1241b22036b827acc53a9baeb3bd0bab63163ab5624bdc75acd4e98ce23d1918b42da53c34
7
- data.tar.gz: 74d5272d0fd7bf782fee52f55cbfb1103461c36573ba28b95c4926ed2b2068d8a8023cb1d70155acec06ce1d07745e0090cb5ea77f1e44ff6cf8582301e307d4
6
+ metadata.gz: 16df1e22865198d992c6fdf0e9540adf2cdb9bdded9d9f5d7e13edbd8b285fef816341ee56da3a7f428dff7d9f58f46e1bf7918ee214efd785a06910554b2d19
7
+ data.tar.gz: 60361b133f271f60ceba9c2c6b939259b817165a141d932cbb26f1b9e80cafd6aac7c0c7b20bce17407d11e64714d99dab72ecb4ffceae2ec911ba26909026c1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportradar-api (0.1.16)
4
+ sportradar-api (0.1.17)
5
5
  activesupport
6
6
  httparty (>= 0.13.3)
7
7
 
@@ -2,24 +2,22 @@ module Sportradar
2
2
  module Api
3
3
  class Soccer::Player < Data
4
4
 
5
- attr_accessor :id, :first_name, :last_name, :country_code, :country, :reference_id, :full_first_name, :full_last_name, :position, :started, :jersey_number, :tactical_position, :tactical_order, :statistics, :preferred_foot, :birthdate, :height_in, :weight_lb, :height_cm, :weight_kg, :teams, :response, :rank, :total, :statistics, :last_modified, :age, :height_ft, :position_name, :tactical_position_name, :name, :full_name
5
+ attr_accessor :id, :first_name, :last_name, :country_code, :country, :reference_id, :full_first_name, :full_last_name, :position, :started, :jersey_number, :tactical_position, :tactical_order, :statistics, :preferred_foot, :birthdate, :height_in, :weight_lb, :height_cm, :weight_kg, :teams, :response, :rank, :total, :statistics, :last_modified
6
6
 
7
7
  def initialize(data)
8
8
  @response = data
9
+ set_teams
9
10
  @id = data["id"]
10
11
  @first_name = data["first_name"]
11
12
  @last_name = data["last_name"]
12
- @name = name
13
13
  @country_code = data["country_code"]
14
14
  @country = data["country"]
15
15
  @reference_id = data["reference_id"]
16
16
  @full_first_name = data["full_first_name"]
17
17
  @full_last_name = data["full_last_name"]
18
- @full_name = full_name
19
- @position = data["position"]
20
-
18
+ @position = data["position"] || primary_team.try(:position)
21
19
  @started = data["started"]
22
- @jersey_number = data["jersey_number"]
20
+ @jersey_number = data["jersey_number"] || primary_team.try(:jersey_number)
23
21
  @tactical_position = data["tactical_position"]
24
22
  @tactical_order = data["tactical_order"]
25
23
  @last_modified = data["last_modified"]
@@ -28,13 +26,9 @@ module Sportradar
28
26
  @preferred_foot = data["preferred_foot"]
29
27
  @birthdate = data["birthdate"]
30
28
  @height_in = data["height_in"]
31
- @height_ft = get_height_ft
32
29
  @weight_lb = data["weight_lb"]
33
30
  @height_cm = data["height_cm"]
34
31
  @weight_kg = data["weight_kg"]
35
- @age = get_age
36
- set_teams
37
- @position_name = get_position_name
38
32
  @rank = data["rank"]
39
33
  @total = OpenStruct.new data["total"] if data["total"]
40
34
 
@@ -50,25 +44,30 @@ module Sportradar
50
44
  full == " " ? name : full
51
45
  end
52
46
 
53
- def get_position_name
54
- positions = {"G" => "Goalie", "D" => "Defender", "M" => "Midfielder", "F" => "Forward"}
55
- if position.present?
47
+ def position_name
48
+ positions = {"G" => "Goalie", "D" => "Defender", "M" => "Midfielder", "F" => "Forward", "" => "N/A"}
49
+ if position
56
50
  positions[position]
57
- elsif teams.present?
58
- teams.map do |team|
59
- if team.position.present?
60
- positions[team.position]
61
- end
62
- end.uniq.join(", ")
51
+ elsif primary_team.present?
52
+ positions[primary_team.position]
63
53
  end
64
54
  end
65
55
 
56
+ def primary_team
57
+ if teams.count == 1
58
+ teams.first
59
+ else
60
+ teams.find {|team| team.name != team.country_code}
61
+ end if teams
62
+ end
63
+
64
+
66
65
  def tactical_position_name
67
66
  tactical_positions = { "0" => "Unknown", "1" => "Goalkeeper", "2" => "Right back", "3" => "Central defender", "4" => "Left back", "5" => "Right winger", "6" => "Central midfielder", "7" => "Left winger", "8" => "Forward" }
68
67
  tactical_positions[tactical_position] if tactical_position
69
68
  end
70
69
 
71
- def get_age
70
+ def age
72
71
  if birthdate.present?
73
72
  now = Time.now.utc.to_date
74
73
  dob = birthdate.to_date
@@ -76,7 +75,7 @@ module Sportradar
76
75
  end
77
76
  end
78
77
 
79
- def get_height_ft
78
+ def height_ft
80
79
  if height_in.present?
81
80
  feet, inches = height_in.to_i.divmod(12)
82
81
  "#{feet}' #{inches}\""
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.1.16"
3
+ VERSION = "0.1.17"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportradar-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett