Class: OdeonUk::Cinema

Inherits:
Cinebase::Cinema
  • Object
show all
Defined in:
lib/odeon_uk/cinema.rb

Overview

The object representing a cinema on the Odeon UK website

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ OdeonUk::Cinema

Constructor

Parameters:

  • id (Integer, String)

    the cinema id of the format 71/'71' as used on


10
11
12
# File 'lib/odeon_uk/cinema.rb', line 10

def initialize(id)
  @id = id.to_s
end

Instance Attribute Details

#idInteger (readonly)

Returns the numeric id of the cinema on the Cineworld website.

Returns:

  • (Integer)

    the numeric id of the cinema on the Cineworld website


# File 'lib/odeon_uk/cinema.rb', line 4

Class Method Details

.allArray<OdeonUk::Cinema>

Return basic cinema information for all cinemas

Examples:

OdeonUk::Cinema.all
#=> [<OdeonUk::Cinema>, <OdeonUk::Cinema>, ...]

Returns:


19
20
21
# File 'lib/odeon_uk/cinema.rb', line 19

def self.all
  cinemas_hash.keys.map { |cinema_id| new(cinema_id) }
end

Instance Method Details

#addressHash

Address of the cinema

Returns:

  • (Hash)

    of different address parts

See Also:


# File 'lib/odeon_uk/cinema.rb', line 23

#adrHash

Note:

Uses the standard method naming as at microformats.org/wiki/adr

Address of the cinema :locality, :postal_code, :country

Examples:

cinema = OdeonUk::Cinema.new(3)
cinema.adr
#=> {
      street_address: '44-47 Gardner Street',
      extended_address: 'North Laine',
      locality: 'Brighton',
      postal_code: 'BN1 1UN',
      country_name: 'United Kingdom'
    }

Returns:

  • (Hash)

    contains :street_address, :extended_address,


42
43
44
45
46
47
48
49
50
51
# File 'lib/odeon_uk/cinema.rb', line 42

def adr
  {
    street_address:   cinema_hash['siteAddress1'],
    extended_address: nil,
    locality:         cinema_hash['siteAddress2'],
    region:           nil,
    postal_code:      cinema_hash['sitePostcode'],
    country_name:     'United Kingdom'.freeze
  }
end

#brandString

Brand of the cinema

Examples:

cinema = OdeonUk::Cinema.new(3)
cinema.brand
#=> 'Odeon'

Returns:

  • (String)

    which will always be 'Odeon'


59
60
61
# File 'lib/odeon_uk/cinema.rb', line 59

def brand
  'Odeon'.freeze
end

#country_nameString

Country of the cinema

Examples:

cinema = CineworldUk::Cinema.new(3)
cinema.country_name
#=> 'United Kingdom'

Returns:

  • (String)

    which will always be 'United Kingdom'


# File 'lib/odeon_uk/cinema.rb', line 63

#extended_addressString

The second address line of the cinema

Examples:

cinema = CineworldUk::Cinema.new(10)
cinema.extended_address
#=> 'Chelsea'

cinema = CineworldUk::Cinema.new(3)
cinema.extended_address
#=> ''

Returns:

  • (String)

# File 'lib/odeon_uk/cinema.rb', line 71

#full_nameString

The name of the cinema including the brand

Examples:

cinema = CineworldUk::Cinema.new(88)
cinema.full_name
#=> 'Cineworld Glasgow: IMAX at GSC'

Returns:

  • (String)

# File 'lib/odeon_uk/cinema.rb', line 83

#localityString

The locality (town) of the cinema

Examples:

cinema = CineworldUk::Cinema.new(3)
cinema.locality
#=> 'Brighton'

Returns:

  • (String)

# File 'lib/odeon_uk/cinema.rb', line 91

#nameString

The name of the cinema

Examples:

cinema = CineworldUk::Cinema.new(3)
cinema.name
#=> 'Brighton'

Returns:

  • (String)

105
106
107
# File 'lib/odeon_uk/cinema.rb', line 105

def name
  @name ||= cinema_hash['siteName'].gsub(/\ALondon /, '').gsub(' - ', ': ')
end

#postal_codeString

Post code of the cinema

Examples:

cinema = CineworldUk::Cinema.new(3)
cinema.postal_code
#=> 'BN2 5UF'

Returns:

  • (String)

# File 'lib/odeon_uk/cinema.rb', line 109

#regionString

The region (county) of the cinema if provided

Examples:

cinema = CineworldUk::Cinema.new(3)
cinema.region
#=> 'East Sussex'

Returns:

  • (String)

# File 'lib/odeon_uk/cinema.rb', line 117

#slugString

The URL-able slug of the cinema

Examples:

cinema = CineworldUk::Cinema.new(3)
cinema.slug
#=> 'odeon-brighton'

Returns:

  • (String)

# File 'lib/odeon_uk/cinema.rb', line 125

#street_addressString

Note:

Uses the standard method naming as at microformats.org/wiki/adr

The street address of the cinema

Examples:

cinema = CineworldUk::Cinema.new(3)
cinema.street_address
#=> 'Brighton Marina'

Returns:

  • (String)

# File 'lib/odeon_uk/cinema.rb', line 133

#urlString

The url of the cinema on the Cineworld website

Returns:

  • (String)

144
145
146
# File 'lib/odeon_uk/cinema.rb', line 144

def url
  "http://www.odeon.co.uk/cinemas/#{urlized_name}/#{id}/"
end