Class: Sportradar::Api::Odds::PlayerProp

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/odds/player_prop.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) ⇒ PlayerProp

Returns a new instance of PlayerProp.



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

def initialize(data, **opts)
  @response = data
  @api      = opts[:api]
  @id       = data.dig("player", "id")

  @markets_hash   = {}

  update(data, **opts)
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



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

def api
  @api
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#marketsObject



18
19
20
# File 'lib/sportradar/api/odds/player_prop.rb', line 18

def markets
  @markets_hash.values
end

#update(data, **opts) ⇒ Object



22
23
24
# File 'lib/sportradar/api/odds/player_prop.rb', line 22

def update(data, **opts)
  create_data(@markets_hash,   data['markets'],    klass: Market,  api: api, player: data['player'])  if data['markets']
end