Class: CineworldUk::Cinema

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

Overview

The object representing a cinema on the Cineworld UK website

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ CineworldUk::Cinema

Constructor

Parameters:

  • id (Integer, String)

    cinema id



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

def initialize(id)
  @id = id.to_i
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/cineworld_uk/cinema.rb', line 4

Class Method Details

.allArray<CineworldUk::Cinema>

Return basic cinema information for all cinemas

Examples:

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

Returns:



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

def self.all
  id_names_hash.map { |id, _| new id }
end

.id_names_hashHash<Integer => String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

called from instance methods

Returns:

  • (Hash<Integer => String>)


26
27
28
29
30
31
# File 'lib/cineworld_uk/cinema.rb', line 26

def self.id_names_hash
  @id_names_hash ||= cinema_list_json.each_with_object({}) do |hash, result|
    result[hash['id']] =
      hash['name'].gsub('London - ', '').gsub(' - ', ': ')
  end
end

Instance Method Details

#addressHash

Address of the cinema

Returns:

  • (Hash)

    of different address parts

See Also:



# File 'lib/cineworld_uk/cinema.rb', line 33

#adrHash

Note:

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

Address of the cinema

Examples:

cinema = CineworldUk::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)

    of different address parts



51
52
53
# File 'lib/cineworld_uk/cinema.rb', line 51

def adr
  CineworldUk::Internal::Parser::Api::CinemaAddress.new(@id).to_hash
end

#brandString

Brand of the cinema

Examples:

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

Returns:

  • (String)

    which will always be ‘Cineworld’



61
62
63
# File 'lib/cineworld_uk/cinema.rb', line 61

def brand
  'Cineworld'.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/cineworld_uk/cinema.rb', line 65

#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/cineworld_uk/cinema.rb', line 73

#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/cineworld_uk/cinema.rb', line 85

#localityString

The locality (town) of the cinema

Examples:

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

Returns:

  • (String)


# File 'lib/cineworld_uk/cinema.rb', line 93

#nameString

The name of the cinema

Examples:

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

Returns:

  • (String)


107
108
109
# File 'lib/cineworld_uk/cinema.rb', line 107

def name
  @name ||= self.class.id_names_hash[id]
end

#postal_codeString

Post code of the cinema

Examples:

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

Returns:

  • (String)


# File 'lib/cineworld_uk/cinema.rb', line 111

#regionString

The region (county) of the cinema if provided

Examples:

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

Returns:

  • (String)


# File 'lib/cineworld_uk/cinema.rb', line 119

#slugString

The URL-able slug of the cinema

Examples:

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

Returns:

  • (String)


# File 'lib/cineworld_uk/cinema.rb', line 127

#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/cineworld_uk/cinema.rb', line 135

#urlString

The url of the cinema on the Cineworld website

Returns:

  • (String)


146
147
148
# File 'lib/cineworld_uk/cinema.rb', line 146

def url
  "http://www.cineworld.co.uk/cinemas/#{@id}/information"
end