sportradar-api 0.1.16 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sportradar/api/soccer/player.rb +20 -21
- data/lib/sportradar/api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: becdba7a870fb4ee7bfc5c2b76f44af5084b5e79
|
4
|
+
data.tar.gz: f64e463d94380a738a0544d193a743978def051d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16df1e22865198d992c6fdf0e9540adf2cdb9bdded9d9f5d7e13edbd8b285fef816341ee56da3a7f428dff7d9f58f46e1bf7918ee214efd785a06910554b2d19
|
7
|
+
data.tar.gz: 60361b133f271f60ceba9c2c6b939259b817165a141d932cbb26f1b9e80cafd6aac7c0c7b20bce17407d11e64714d99dab72ecb4ffceae2ec911ba26909026c1
|
data/Gemfile.lock
CHANGED
@@ -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
|
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
|
-
@
|
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
|
54
|
-
positions = {"G" => "Goalie", "D" => "Defender", "M" => "Midfielder", "F" => "Forward"}
|
55
|
-
if position
|
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
|
58
|
-
|
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
|
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
|
78
|
+
def height_ft
|
80
79
|
if height_in.present?
|
81
80
|
feet, inches = height_in.to_i.divmod(12)
|
82
81
|
"#{feet}' #{inches}\""
|