Class: Sportradar::Api::Odds::Sport

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/odds/sport.rb

Instance Attribute 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, **opts) ⇒ Sport

Returns a new instance of Sport.



8
9
10
11
12
13
14
15
16
17
# File 'lib/sportradar/api/odds/sport.rb', line 8

def initialize(data, **opts)
  @response = data
  @api      = opts[:api]

  @id       = data['id']
  @name     = data['name']
  @type     = data['type']

  @competitions_hash = {}
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



5
6
7
# File 'lib/sportradar/api/odds/sport.rb', line 5

def api
  @api
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/odds/sport.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/sportradar/api/odds/sport.rb', line 5

def name
  @name
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/odds/sport.rb', line 5

def response
  @response
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/sportradar/api/odds/sport.rb', line 5

def type
  @type
end

Instance Method Details

#competitionsObject



24
25
26
# File 'lib/sportradar/api/odds/sport.rb', line 24

def competitions
  @competitions_hash.values
end

#get_competitionsObject



28
29
30
31
32
# File 'lib/sportradar/api/odds/sport.rb', line 28

def get_competitions
  data = api.get_data(path_competitions);
  create_data(@competitions_hash, data['competitions'], klass: Sport, api: api)
  data
end

#path_baseObject

url path helpers



35
36
37
# File 'lib/sportradar/api/odds/sport.rb', line 35

def path_base
  "sports/#{id}"
end

#path_competitionsObject



39
40
41
# File 'lib/sportradar/api/odds/sport.rb', line 39

def path_competitions
  "#{path_base}/competitions"
end

#update(data, **opts) ⇒ Object



19
20
21
# File 'lib/sportradar/api/odds/sport.rb', line 19

def update(data, **opts)

end