Class: Sportradar::Api::Mma::Venue

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/mma/venue.rb

Constant Summary collapse

KEYS_SCHED =
["id", "name", "scheduled", "venue", "league", "fights"]

Instance Attribute Summary collapse

Class Method 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) ⇒ Venue

Returns a new instance of Venue.



21
22
23
24
25
26
27
28
29
30
# File 'lib/sportradar/api/mma/venue.rb', line 21

def initialize(data, **opts)
  @response = data
  @api      = opts[:api]
  @event    = opts[:event]
  @events_hash = {}

  @id       = data['id']

  update(data)
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



5
6
7
# File 'lib/sportradar/api/mma/venue.rb', line 5

def address
  @address
end

#capacityObject

Returns the value of attribute capacity.



5
6
7
# File 'lib/sportradar/api/mma/venue.rb', line 5

def capacity
  @capacity
end

#cityObject

Returns the value of attribute city.



5
6
7
# File 'lib/sportradar/api/mma/venue.rb', line 5

def city
  @city
end

#countryObject

Returns the value of attribute country.



5
6
7
# File 'lib/sportradar/api/mma/venue.rb', line 5

def country
  @country
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/mma/venue.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/sportradar/api/mma/venue.rb', line 5

def name
  @name
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/mma/venue.rb', line 5

def response
  @response
end

#stateObject

Returns the value of attribute state.



5
6
7
# File 'lib/sportradar/api/mma/venue.rb', line 5

def state
  @state
end

#timezoneObject

Returns the value of attribute timezone.



5
6
7
# File 'lib/sportradar/api/mma/venue.rb', line 5

def timezone
  @timezone
end

#zipObject

Returns the value of attribute zip.



5
6
7
# File 'lib/sportradar/api/mma/venue.rb', line 5

def zip
  @zip
end

Class Method Details

.allObject



17
18
19
# File 'lib/sportradar/api/mma/venue.rb', line 17

def self.all
  @all_hash.values
end

.new(data, **opts) ⇒ Object



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

def self.new(data, **opts)
  existing = @all_hash[data['name']]
  if existing
    existing.update(data)
    existing.add_event(opts[:event])
    existing
  else
    @all_hash[data['name']] = super
  end
end

Instance Method Details

#add_event(event) ⇒ Object



35
36
37
# File 'lib/sportradar/api/mma/venue.rb', line 35

def add_event(event)
  @events_hash[event.id] = event if event
end

#apiObject



54
55
56
# File 'lib/sportradar/api/mma/venue.rb', line 54

def api
  @api ||= Sportradar::Api::Mma.new
end

#eventsObject



32
33
34
# File 'lib/sportradar/api/mma/venue.rb', line 32

def events
  @events_hash.values
end

#update(data, **opts) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/sportradar/api/mma/venue.rb', line 39

def update(data, **opts)
  @name         = data['name']
  @country_code = data['country_code']
  @country      = data['country']
  @state        = data['state']
  @city         = data['city']

  @id         = @name + ', ' + @city

  self
end