Class: Sportradar::Api::Mma::Venue
- Defined in:
- lib/sportradar/api/mma/venue.rb
Constant Summary collapse
- KEYS_SCHED =
["id", "name", "scheduled", "venue", "league", "fights"]
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#capacity ⇒ Object
Returns the value of attribute capacity.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#response ⇒ Object
Returns the value of attribute response.
-
#state ⇒ Object
Returns the value of attribute state.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
-
#zip ⇒ Object
Returns the value of attribute zip.
Class Method Summary collapse
Instance Method Summary collapse
- #add_event(event) ⇒ Object
- #api ⇒ Object
- #events ⇒ Object
-
#initialize(data, **opts) ⇒ Venue
constructor
A new instance of Venue.
- #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) ⇒ 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
#address ⇒ Object
Returns the value of attribute address.
5 6 7 |
# File 'lib/sportradar/api/mma/venue.rb', line 5 def address @address end |
#capacity ⇒ Object
Returns the value of attribute capacity.
5 6 7 |
# File 'lib/sportradar/api/mma/venue.rb', line 5 def capacity @capacity end |
#city ⇒ Object
Returns the value of attribute city.
5 6 7 |
# File 'lib/sportradar/api/mma/venue.rb', line 5 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
5 6 7 |
# File 'lib/sportradar/api/mma/venue.rb', line 5 def country @country end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/mma/venue.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/sportradar/api/mma/venue.rb', line 5 def name @name end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/mma/venue.rb', line 5 def response @response end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/sportradar/api/mma/venue.rb', line 5 def state @state end |
#timezone ⇒ Object
Returns the value of attribute timezone.
5 6 7 |
# File 'lib/sportradar/api/mma/venue.rb', line 5 def timezone @timezone end |
#zip ⇒ Object
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
.all ⇒ Object
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 |
#api ⇒ Object
54 55 56 |
# File 'lib/sportradar/api/mma/venue.rb', line 54 def api @api ||= Sportradar::Api::Mma.new end |
#events ⇒ Object
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 |