class OdeonUk::Cinema

The object representing a cinema on the Odeon UK website

Public Class Methods

all() click to toggle source

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

OdeonUk::Cinema.all
#=> [<OdeonUk::Cinema>, <OdeonUk::Cinema>, ...]
# File lib/odeon_uk/cinema.rb, line 19
def self.all
  cinemas_hash.keys.map { |cinema_id| new(cinema_id) }
end
new(id) click to toggle source

Constructor @param [Integer, String] id the cinema id of the format 71/‘71’ as used on @return [OdeonUk::Cinema]

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

Private Class Methods

cinemas_hash() click to toggle source
# File lib/odeon_uk/cinema.rb, line 150
def self.cinemas_hash
  @cinemas_hash ||=
    OdeonUk::Internal::ApiResponse.new.all_cinemas.fetch('sites', {})
end

Public Instance Methods

adr() click to toggle source

Address of the cinema @return [Hash] contains :street_address, :extended_address, :locality, :postal_code, :country @example

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

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

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

Brand of the cinema @return [String] which will always be ‘Odeon’ @example

cinema = OdeonUk::Cinema.new(3)
cinema.brand
#=> 'Odeon'
# File lib/odeon_uk/cinema.rb, line 59
def brand
  'Odeon'.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/odeon_uk/cinema.rb, line 105
def name
  @name ||= cinema_hash['siteName'].gsub(/\ALondon /, '').gsub(' - ', ': ')
end
url() click to toggle source

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

# File lib/odeon_uk/cinema.rb, line 144
def url
  "http://www.odeon.co.uk/cinemas/#{urlized_name}/#{id}/"
end

Private Instance Methods

cinema_hash() click to toggle source
# File lib/odeon_uk/cinema.rb, line 155
def cinema_hash
  @cinema_hash ||= self.class.cinemas_hash.fetch(id, {})
end
urlized_name() click to toggle source
# File lib/odeon_uk/cinema.rb, line 159
def urlized_name
  name.downcase.gsub(/[^a-z0-9]/, '_')
end