Class: EspnPub::Entities::Venue

Inherits:
Base
  • Object
show all
Defined in:
lib/espn_pub/entities/venue.rb

Overview

Represents a team's home venue (stadium or arena).

Instance Attribute Summary collapse

Attributes inherited from Base

#client

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, full_name: nil, short_name: nil, city: nil, state: nil, zip_code: nil, country: nil, indoor: nil, grass: nil) ⇒ Venue

Initialize a Venue entity.

Parameters:

  • id (String)

    The venue identifier.

  • full_name (String, nil) (defaults to: nil)

    The venue's full name.

  • short_name (String, nil) (defaults to: nil)

    The venue's short name.

  • city (String, nil) (defaults to: nil)

    The venue's city.

  • state (String, nil) (defaults to: nil)

    The venue's state or province.

  • zip_code (String, nil) (defaults to: nil)

    The venue's postal code.

  • country (String, nil) (defaults to: nil)

    The venue's country.

  • indoor (Boolean, nil) (defaults to: nil)

    Whether the venue is indoors.

  • grass (Boolean, nil) (defaults to: nil)

    Whether the venue has a grass surface.



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/espn_pub/entities/venue.rb', line 28

def initialize(id:, full_name: nil, short_name: nil, city: nil, state: nil, zip_code: nil, country: nil,
               indoor: nil, grass: nil)
  @id = id
  @full_name = full_name
  @short_name = short_name
  @city = city
  @state = state
  @zip_code = zip_code
  @country = country
  @indoor = indoor
  @grass = grass
  super()
end

Instance Attribute Details

#cityObject (readonly)

Returns the value of attribute city.



7
8
9
# File 'lib/espn_pub/entities/venue.rb', line 7

def city
  @city
end

#countryObject (readonly)

Returns the value of attribute country.



7
8
9
# File 'lib/espn_pub/entities/venue.rb', line 7

def country
  @country
end

#full_nameObject (readonly)

Returns the value of attribute full_name.



7
8
9
# File 'lib/espn_pub/entities/venue.rb', line 7

def full_name
  @full_name
end

#grassObject (readonly)

Returns the value of attribute grass.



7
8
9
# File 'lib/espn_pub/entities/venue.rb', line 7

def grass
  @grass
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/espn_pub/entities/venue.rb', line 7

def id
  @id
end

#indoorObject (readonly)

Returns the value of attribute indoor.



7
8
9
# File 'lib/espn_pub/entities/venue.rb', line 7

def indoor
  @indoor
end

#short_nameObject (readonly)

Returns the value of attribute short_name.



7
8
9
# File 'lib/espn_pub/entities/venue.rb', line 7

def short_name
  @short_name
end

#stateObject (readonly)

Returns the value of attribute state.



7
8
9
# File 'lib/espn_pub/entities/venue.rb', line 7

def state
  @state
end

#zip_codeObject (readonly)

Returns the value of attribute zip_code.



7
8
9
# File 'lib/espn_pub/entities/venue.rb', line 7

def zip_code
  @zip_code
end

Class Method Details

.from_api(data) ⇒ Venue?

Build a Venue from ESPN API venue data.

Parameters:

  • data (Hash, nil)

    Raw venue data from the API.

Returns:

  • (Venue, nil)

    A Venue instance, or nil when data is absent.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/espn_pub/entities/venue.rb', line 46

def self.from_api(data)
  return nil unless data

  new(
    id: data['id'],
    full_name: data['fullName'],
    short_name: data['shortName'],
    city: data.dig('address', 'city'),
    state: data.dig('address', 'state'),
    zip_code: data.dig('address', 'zipCode'),
    country: data.dig('address', 'country'),
    indoor: data['indoor'],
    grass: data['grass']
  )
end