Class: PicturehouseUk::Cinema

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

Overview

The object representing a cinema on the Picturehouse UK website

Constant Summary collapse

ADDRESS_CSS =

address css

'.box6 .txt6'
'#cinemalisthome .cinemas a'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ PicturehouseUk::Cinema

Parameters:

  • options (Hash)

    id, name and url of the cinemas



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/picturehouse_uk/cinema.rb', line 22

def initialize(options)
  @brand = 'Picturehouse'
  @id    = options[:id]
  @name  = options[:name]
  @slug  = @name.downcase.gsub(/[^0-9a-z ]/, '').gsub(/\s+/, '-')
  @url   = if options[:url][0] == '/'
             "http://www.picturehouses.co.uk#{options[:url]}"
           else
             options[:url]
           end
end

Instance Attribute Details

#brandString (readonly)

Returns the brand of the cinema.

Returns:

  • (String)

    the brand of the cinema



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

def brand
  @brand
end

#idString (readonly)

Returns the id of the cinema on the Picturehouse website.

Returns:

  • (String)

    the id of the cinema on the Picturehouse website



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

def id
  @id
end

#nameString (readonly)

Returns the name of the cinema.

Returns:

  • (String)

    the name of the cinema



14
15
16
# File 'lib/picturehouse_uk/cinema.rb', line 14

def name
  @name
end

#slugString (readonly)

Returns the slug of the cinema.

Returns:

  • (String)

    the slug of the cinema



16
17
18
# File 'lib/picturehouse_uk/cinema.rb', line 16

def slug
  @slug
end

#urlString (readonly)

Returns the url of the cinema on the Picturehouse website.

Returns:

  • (String)

    the url of the cinema on the Picturehouse website



18
19
20
# File 'lib/picturehouse_uk/cinema.rb', line 18

def url
  @url
end

Class Method Details

.allArray<PicturehouseUk::Cinema>

Return basic cinema information for all cinemas

Examples:

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

Returns:



39
40
41
# File 'lib/picturehouse_uk/cinema.rb', line 39

def self.all
  cinema_links.map { |link| new_from_link(link) }
end

.find(id) ⇒ PicturehouseUk::Cinema?

Find a single cinema

Examples:

PicturehouseUk::Cinema.find('Dukes_At_Komedia')
# => <PicturehouseUK::Cinema ...>

Parameters:

  • id (String)

    the cinema id as used on the picturehouses.co.uk website

Returns:



49
50
51
# File 'lib/picturehouse_uk/cinema.rb', line 49

def self.find(id)
  all.find { |cinema| cinema.id == id }
end

Instance Method Details

#adrHash Also known as: address

Note:

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

Address of the cinema

Examples:

cinema = PicturehouseUk::Cinema.find('Dukes_At_Komedia')
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



66
67
68
# File 'lib/picturehouse_uk/cinema.rb', line 66

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

#extended_addressString?

Note:

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

The second address line of of the cinema

Examples:

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

Returns:

  • (String, nil)


78
79
80
# File 'lib/picturehouse_uk/cinema.rb', line 78

def extended_address
  address[:extended_address]
end

#filmsArray<PicturehouseUk::Film>

Films with showings scheduled at this cinema

Examples:

cinema = PicturehouseUk::Cinema.find('Dukes_At_Komedia')
cinema.films
# => [<PicturehouseUk::Film ...>, <PicturehouseUk::Film ...>, ...]

Returns:



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

def films
  PicturehouseUk::Film.at(@id)
end

#full_nameString

The name of the cinema (might include brand)

Examples:

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

Returns:

  • (String)


98
99
100
# File 'lib/picturehouse_uk/cinema.rb', line 98

def full_name
  name
end

#localityString

Note:

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

The locality (town) of the cinema

Examples:

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

Returns:

  • (String)


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

def locality
  address[:locality]
end

#postal_codeString

Note:

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

Post code of the cinema

Examples:

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

Returns:

  • (String)


120
121
122
# File 'lib/picturehouse_uk/cinema.rb', line 120

def postal_code
  address[:postal_code]
end

#screeningsArray<PicturehouseUk::Screening>

All planned screenings

Examples:

cinema = PicturehouseUk::Cinema.find('Dukes_At_Komedia')
cinema.screenings
# => [<PicturehouseUk::Screening ...>, <PicturehouseUk::Screening ...>]

Returns:



130
131
132
# File 'lib/picturehouse_uk/cinema.rb', line 130

def screenings
  PicturehouseUk::Screening.at(@id)
end

#street_addressObject

Note:

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

The street adress of the cinema

Examples:

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

Returns:

  • a String



141
142
143
# File 'lib/picturehouse_uk/cinema.rb', line 141

def street_address
  address[:street_address]
end