Class: PicturehouseUk::Cinema

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

Overview

The object representing a cinema on the Picturehouse UK website

Defined Under Namespace

Classes: ListParser

Constant Summary collapse

ADDRESS_CSS =

address css

'.static-content #contact-us + p:first'.freeze
'.footer .col-sm-3 option + option'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ PicturehouseUk::Cinema

Constructor

Parameters:

  • id (String)

    the cinema id of the cinema in capitalized snake case



# File 'lib/picturehouse_uk/cinema.rb', line 12

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/picturehouse_uk/cinema.rb', line 9

Class Method Details

.allArray<PicturehouseUk::Cinema>

Return basic cinema information for all cinemas

Examples:

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

Returns:



22
23
24
# File 'lib/picturehouse_uk/cinema.rb', line 22

def self.all
  cinema_hash.keys.map { |id| new(id) }
end

.cinema_hashObject

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.



27
28
29
# File 'lib/picturehouse_uk/cinema.rb', line 27

def self.cinema_hash
  @cinema_hash ||= ListParser.new(cinema_links).to_hash
end

Instance Method Details

#addressHash

Address of the cinema

Returns:

  • (Hash)

    of different address parts

See Also:



# File 'lib/picturehouse_uk/cinema.rb', line 31

#adrHash

Note:

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

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

Examples:

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

Returns:

  • (Hash)

    contains :street_address, :extended_address,



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

def adr
  PicturehouseUk::Internal::Parser::Address.new(address_node.to_s).address
end

#brandString

Brand of the cinema

Examples:

cinema = PicturehouseUk::Cinema.new('Dukes_At_Komedia')
cinema.brand
#=> 'Picturehouse'

Returns:

  • (String)

    which will always be ‘Picturehouse’



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

def brand
  'Picturehouse'.freeze
end

#country_nameString

Country of the cinema

Examples:

cinema = PicturehouseUk::Cinema.new('Dukes_At_Komedia')
cinema.country_name
#=> 'United Kingdom'

Returns:

  • (String)

    which will always be ‘United Kingdom’



# File 'lib/picturehouse_uk/cinema.rb', line 65

#extended_addressString

The second address line of the cinema

Examples:

cinema = PicturehouseUk::Cinema.new('Dukes_At_Komedia')
cinema.extended_address
#=> 'North Laine'

Returns:

  • (String)


# File 'lib/picturehouse_uk/cinema.rb', line 73

#full_nameString

The name of the cinema (might include brand)

Examples:

cinema = PicturehouseUk::Cinema.new('Dukes_At_Komedia')
cinema.full_name
#=> "Duke's At Komedia"

Returns:

  • (String)


87
88
89
# File 'lib/picturehouse_uk/cinema.rb', line 87

def full_name
  name
end

#localityString

The locality (town) of the cinema

Examples:

cinema = PicturehouseUk::Cinema.new('Dukes_At_Komedia')
cinema.locality
#=> 'Brighton'

Returns:

  • (String)


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

#nameString

The name of the cinema

Examples:

cinema = PicturehouseUk::Cinema.new('Dukes_At_Komedia')
cinema.name
#=> "Duke's At Komedia"

Returns:

  • (String)


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

def name
  self.class.cinema_hash.fetch(id, {})[:name]
end

#postal_codeString

Post code of the cinema

Examples:

cinema = PicturehouseUk::Cinema.new('Dukes_At_Komedia')
cinema.postal_code
#=> 'BN1 1UN'

Returns:

  • (String)


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

#regionString

The region (county) of the cinema if provided

Examples:

cinema = PicturehouseUk::Cinema.new('Dukes_At_Komedia')
cinema.region
#=> 'East Sussex'

Returns:

  • (String)


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

#slugString

The URL-able slug of the cinema

Examples:

cinema = PicturehouseUk::Cinema.new('Dukes_At_Komedia')
cinema.slug
#=> 'dukes-at-komedia'

Returns:

  • (String)


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

#street_addressString

The street address of the cinema

Examples:

cinema = PicturehouseUk::Cinema.new('Dukes_At_Komedia')
cinema.street_address
#=> '44-47 Gardner Street'

Returns:

  • (String)


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

#urlString

The url of the cinema on the Picturehouse website

Returns:

  • (String)


143
144
145
# File 'lib/picturehouse_uk/cinema.rb', line 143

def url
  "http://www.picturehouses.com#/cinema/#{id}"
end