Class: Sportradar::Api::Odds::Player
- Defined in:
- lib/sportradar/api/odds/player.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) ⇒ Player
constructor
A new instance of Player.
- #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) ⇒ Player
Returns a new instance of Player.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/sportradar/api/odds/player.rb', line 8 def initialize(data, **opts) @response = data @api = opts[:api] @id = data['id'] || data.dig('player', 'id') @props_hash = {} update(data['player']) if data['player'] update(data) end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
5 6 7 |
# File 'lib/sportradar/api/odds/player.rb', line 5 def api @api end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/odds/player.rb', line 5 def id @id end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/odds/player.rb', line 5 def response @response end |
Instance Method Details
#update(data, **opts) ⇒ Object
19 20 21 22 23 |
# File 'lib/sportradar/api/odds/player.rb', line 19 def update(data, **opts) # @name ||= data['name'] if data['name'] create_data(@props_hash, data['markets'], klass: Player, api: api) if data['markets'] end |