class CineworldUk::Cinema

The object representing a cinema on the Cineworld UK website

Public Class Methods

all() click to toggle source

Return basic cinema information for all cinemas @return [Array<CineworldUk::Cinema>] @example

CineworldUk::Cinema.all
#=> [<CineworldUk::Cinema>, <CineworldUk::Cinema>, ...]
# File lib/cineworld_uk/cinema.rb, line 19
def self.all
  id_names_hash.map { |id, _| new id }
end
id_names_hash() click to toggle source

@api private called from instance methods @return [Hash<Integer => String>]

# 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
new(id) click to toggle source

Constructor @param [Integer, String] id cinema id @return [CineworldUk::Cinema]

# File lib/cineworld_uk/cinema.rb, line 10
def initialize(id)
  @id = id.to_i
end

Private Class Methods

api() click to toggle source

@api private

# File lib/cineworld_uk/cinema.rb, line 153
def self.api
  @api ||= CineworldUk::Internal::ApiResponse.new
end
cinema_list_json() click to toggle source

@api private

# File lib/cineworld_uk/cinema.rb, line 159
def self.cinema_list_json
  @cinema_list_json ||=
    JSON.parse(api.cinema_list)['cinemas']
end

Public Instance Methods

adr() click to toggle source

Address of the cinema @return [Hash] of different address parts @example

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'
    }

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

# File lib/cineworld_uk/cinema.rb, line 51
def adr
  CineworldUk::Internal::Parser::Api::CinemaAddress.new(@id).to_hash
end
brand() click to toggle source

Brand of the cinema @return [String] which will always be 'Cineworld' @example

cinema = CineworldUk::Cinema.new(3)
cinema.brand
#=> 'Cineworld'
# File lib/cineworld_uk/cinema.rb, line 61
def brand
  'Cineworld'.freeze
end
name() click to toggle source

The name of the cinema @return [String] @example

cinema = CineworldUk::Cinema.new(3)
cinema.name
#=> 'Brighton'
# File lib/cineworld_uk/cinema.rb, line 107
def name
  @name ||= self.class.id_names_hash[id]
end
url() click to toggle source

The url of the cinema on the Cineworld website @return [String]

# File lib/cineworld_uk/cinema.rb, line 146
def url
  "http://www.cineworld.co.uk/cinemas/#{@id}/information"
end