Class: Sportradar::Api::Baseball::Venue

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

Constant Summary collapse

KEYS_SCHEDULE =
["id", "name", "capacity", "address", "city", "state", "zip", "country"]

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.



20
21
22
23
24
25
# File 'lib/sportradar/api/baseball/venue.rb', line 20

def initialize(data, **opts)
  @response = data
  @id       = data["id"]

  update(data, **opts)
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



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

def address
  @address
end

#capacityObject

Returns the value of attribute capacity.



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

def capacity
  @capacity
end

#cityObject

Returns the value of attribute city.



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

def city
  @city
end

#countryObject

Returns the value of attribute country.



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

def country
  @country
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

#timezoneObject

Returns the value of attribute timezone.



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

def timezone
  @timezone
end

#zipObject

Returns the value of attribute zip.



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

def zip
  @zip
end

Class Method Details

.allObject



16
17
18
# File 'lib/sportradar/api/baseball/venue.rb', line 16

def self.all
  @all_hash.values
end

.new(data, **opts) ⇒ Object



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

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

Instance Method Details

#locationObject



41
42
43
# File 'lib/sportradar/api/baseball/venue.rb', line 41

def location
  "#{name}, #{city}"
end

#update(data, **opts) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sportradar/api/baseball/venue.rb', line 26

def update(data, **opts)
  @name     = data['name']
  @address  = data['address']
  @city     = data['city']
  @state    = data['state']
  @zip      = data['zip']
  @country  = data['country']
  @capacity = data['capacity']
  @timezone = data['timezone']

  @surface  = data['surface']

  # dimensions
end