Class: Sportradar::Api::Odds::Sport
- Defined in:
- lib/sportradar/api/odds/sport.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#response ⇒ Object
Returns the value of attribute response.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #competitions ⇒ Object
- #get_competitions ⇒ Object
-
#initialize(data, **opts) ⇒ Sport
constructor
A new instance of Sport.
-
#path_base ⇒ Object
url path helpers.
- #path_competitions ⇒ Object
- #update(data, **opts) ⇒ Object
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
#api ⇒ Object
Returns the value of attribute api.
5 6 7 |
# File 'lib/sportradar/api/odds/sport.rb', line 5 def api @api end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/odds/sport.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/sportradar/api/odds/sport.rb', line 5 def name @name end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/odds/sport.rb', line 5 def response @response end |
#type ⇒ Object
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
#competitions ⇒ Object
24 25 26 |
# File 'lib/sportradar/api/odds/sport.rb', line 24 def competitions @competitions_hash.values end |
#get_competitions ⇒ Object
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_base ⇒ Object
url path helpers
35 36 37 |
# File 'lib/sportradar/api/odds/sport.rb', line 35 def path_base "sports/#{id}" end |
#path_competitions ⇒ Object
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 |