Class: Sportradar::Api::Odds::SportEvent
- Defined in:
- lib/sportradar/api/odds/sport_event.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#id ⇒ Object
Returns the value of attribute id.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(data, **opts) ⇒ SportEvent
constructor
A new instance of SportEvent.
- #player_markets ⇒ Object
- #player_props ⇒ 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) ⇒ SportEvent
Returns a new instance of SportEvent.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sportradar/api/odds/sport_event.rb', line 8 def initialize(data, **opts) @response = data @api = opts[:api] @id = data['id'] || data.dig('sport_event', 'id') @player_props_hash = {} @player_markets_hash = {} update(data) # update(data['sport_event']) if data['sport_event'] # update(data['players_props']) if data['players_props'] # update(data['players_markets']) if data['players_markets'] end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
5 6 7 |
# File 'lib/sportradar/api/odds/sport_event.rb', line 5 def api @api end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/odds/sport_event.rb', line 5 def id @id end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/odds/sport_event.rb', line 5 def response @response end |
Instance Method Details
#player_markets ⇒ Object
26 27 28 |
# File 'lib/sportradar/api/odds/sport_event.rb', line 26 def player_markets @player_markets_hash.values end |
#player_props ⇒ Object
22 23 24 |
# File 'lib/sportradar/api/odds/sport_event.rb', line 22 def player_props @player_props_hash.values end |
#update(data, **opts) ⇒ Object
30 31 32 33 |
# File 'lib/sportradar/api/odds/sport_event.rb', line 30 def update(data, **opts) create_data(@player_props_hash, data['players_props'], klass: PlayerProp, api: api) if data['players_props'] create_data(@player_markets_hash, data['players_markets'], klass: Market, api: api) if data['players_markets'] end |