Class: Sportradar::Api::Soccer::Group
- Inherits:
-
Data
- Object
- Data
- Sportradar::Api::Soccer::Group
show all
- Defined in:
- lib/sportradar/api/soccer/group.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Data
#all_attributes, #attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data
Constructor Details
#initialize(data = {}, league_group: nil, **opts) ⇒ Group
Returns a new instance of Group.
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/sportradar/api/soccer/group.rb', line 7
def initialize(data = {}, league_group: nil, **opts)
@id = data['id']
@league_group = league_group || data['league_group']
@tournaments_hash = {}
update(data, **opts)
end
|
Instance Attribute Details
#league_group ⇒ Object
Returns the value of attribute league_group.
5
6
7
|
# File 'lib/sportradar/api/soccer/group.rb', line 5
def league_group
@league_group
end
|
Class Method Details
.americas ⇒ Object
56
57
58
|
# File 'lib/sportradar/api/soccer/group.rb', line 56
def self.americas
self.new(league_group: 'am')
end
|
.europe ⇒ Object
53
54
55
|
# File 'lib/sportradar/api/soccer/group.rb', line 53
def self.europe
self.new(league_group: 'eu')
end
|
.international ⇒ Object
63
64
65
|
# File 'lib/sportradar/api/soccer/group.rb', line 63
def self.international
self.new(league_group: 'intl')
end
|
.north_america ⇒ Object
59
60
61
|
# File 'lib/sportradar/api/soccer/group.rb', line 59
def self.north_america
self.new(league_group: 'na')
end
|
Instance Method Details
#api ⇒ Object
30
31
32
|
# File 'lib/sportradar/api/soccer/group.rb', line 30
def api
@api ||= Sportradar::Api::Soccer::Api.new(league_group: @league_group)
end
|
#get_tournaments ⇒ Object
34
35
36
37
|
# File 'lib/sportradar/api/soccer/group.rb', line 34
def get_tournaments
data = api.get_data(path_tournaments).to_h
ingest_tournaments(data)
end
|
#ingest_tournaments(data) ⇒ Object
39
40
41
42
|
# File 'lib/sportradar/api/soccer/group.rb', line 39
def ingest_tournaments(data)
update(data, source: :tournaments)
data
end
|
#path_tournaments ⇒ Object
49
50
51
|
# File 'lib/sportradar/api/soccer/group.rb', line 49
def path_tournaments
'tournaments'
end
|
#queue_tournaments ⇒ Object
44
45
46
47
|
# File 'lib/sportradar/api/soccer/group.rb', line 44
def queue_tournaments
url, , options, timeout = api.get_request_info(path_tournaments)
{url: url, headers: , params: options, timeout: timeout, callback: method(:ingest_tournaments)}
end
|
#tournament(id) ⇒ Object
26
27
28
|
# File 'lib/sportradar/api/soccer/group.rb', line 26
def tournament(id)
@tournaments_hash[id]
end
|
#tournaments ⇒ Object
22
23
24
|
# File 'lib/sportradar/api/soccer/group.rb', line 22
def tournaments
@tournaments_hash.values
end
|
#update(data, **opts) ⇒ Object
18
19
20
|
# File 'lib/sportradar/api/soccer/group.rb', line 18
def update(data, **opts)
create_data(@tournaments_hash, data['tournaments'], klass: Tournament, api: api, league_group: @league_group) if data['tournaments']
end
|