Class: Sportradar::Api::Odds::Market

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

Returns a new instance of Market.



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

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

  @id       = data['id']
  @name     = data['name']
  @player   = opts['player']

  @book_markets_hash = {}

  update(data, **opts)
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#playerObject

Returns the value of attribute player.



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

def player
  @player
end

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#book_marketsObject



21
22
23
# File 'lib/sportradar/api/odds/market.rb', line 21

def book_markets
  @book_markets_hash.values
end

#update(data, **opts) ⇒ Object



25
26
27
# File 'lib/sportradar/api/odds/market.rb', line 25

def update(data, **opts)
  create_data(@book_markets_hash, data['books'], klass: BookMarket, api: @api, market: self, player: @player) if data['books']
end