Class: CineworldUk::Cinema
- Inherits:
-
Object
- Object
- CineworldUk::Cinema
- Defined in:
- lib/cineworld_uk/cinema.rb
Overview
The object representing a cinema on the Cineworld UK website
Instance Attribute Summary collapse
-
#brand ⇒ String
readonly
The brand of the cinema.
-
#id ⇒ Integer
readonly
The numeric id of the cinema on the Cineworld website.
-
#name ⇒ String
readonly
The name of the cinema.
-
#slug ⇒ String
readonly
The slug of the cinema.
-
#url ⇒ String
readonly
The url of the cinema on the Cineworld website.
Class Method Summary collapse
-
.all ⇒ Array<CineworldUk::Cinema>
Return basic cinema information for all cinemas.
-
.find(id) ⇒ CineworldUk::Cinema?
Find a single cinema.
Instance Method Summary collapse
-
#adr ⇒ Hash
(also: #address)
Address of the cinema.
-
#extended_address ⇒ String?
The second address line of the cinema.
-
#films ⇒ Array<CineworldUk::Film>
Films with showings scheduled at this cinema.
-
#full_name ⇒ String
The name of the cinema including the brand.
- #initialize(id, name) ⇒ CineworldUk::Cinema constructor
-
#locality ⇒ String
The locality (town) of the cinema.
-
#postal_code ⇒ String
Post code of the cinema.
-
#region ⇒ String?
The region (county) of the cinema if provided.
-
#screenings ⇒ Array<CineworldUk::Screening>
All planned screenings.
-
#street_address ⇒ Object
The street adress of the cinema.
Constructor Details
#initialize(id, name) ⇒ CineworldUk::Cinema
18 19 20 21 22 23 24 |
# File 'lib/cineworld_uk/cinema.rb', line 18 def initialize(id, name) @brand = 'Cineworld' @id = id.to_i @name = name.gsub('London - ', '').gsub(' - ', ': ') @slug = @name.downcase.gsub(/[^0-9a-z ]/, '').gsub(/\s+/, '-') @url = "http://www.cineworld.co.uk/cinemas/#{@id}/information" end |
Instance Attribute Details
#brand ⇒ String (readonly)
Returns the brand of the cinema.
5 6 7 |
# File 'lib/cineworld_uk/cinema.rb', line 5 def brand @brand end |
#id ⇒ Integer (readonly)
Returns the numeric id of the cinema on the Cineworld website.
7 8 9 |
# File 'lib/cineworld_uk/cinema.rb', line 7 def id @id end |
#name ⇒ String (readonly)
Returns the name of the cinema.
9 10 11 |
# File 'lib/cineworld_uk/cinema.rb', line 9 def name @name end |
#slug ⇒ String (readonly)
Returns the slug of the cinema.
11 12 13 |
# File 'lib/cineworld_uk/cinema.rb', line 11 def slug @slug end |
#url ⇒ String (readonly)
Returns the url of the cinema on the Cineworld website.
13 14 15 |
# File 'lib/cineworld_uk/cinema.rb', line 13 def url @url end |
Class Method Details
.all ⇒ Array<CineworldUk::Cinema>
Return basic cinema information for all cinemas
31 32 33 34 35 |
# File 'lib/cineworld_uk/cinema.rb', line 31 def self.all cinemas_doc.css('#cinemaId option[value]').map do |option| new option['value'], option.text end[1..-1] end |
.find(id) ⇒ CineworldUk::Cinema?
Find a single cinema
47 48 49 |
# File 'lib/cineworld_uk/cinema.rb', line 47 def self.find(id) all.select { |cinema| cinema.id == id.to_i }[0] end |
Instance Method Details
#adr ⇒ Hash Also known as: address
Uses the standard method naming as at microformats.org/wiki/adr
Address of the cinema
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cineworld_uk/cinema.rb', line 64 def adr { street_address: street_address, extended_address: extended_address, locality: locality, region: region, postal_code: postal_code, country: 'United Kingdom' } end |
#extended_address ⇒ String?
Uses the standard method naming as at microformats.org/wiki/adr
The second address line of the cinema
87 88 89 |
# File 'lib/cineworld_uk/cinema.rb', line 87 def extended_address remaining_address * ', ' unless remaining_address.empty? end |
#films ⇒ Array<CineworldUk::Film>
Films with showings scheduled at this cinema
97 98 99 |
# File 'lib/cineworld_uk/cinema.rb', line 97 def films Film.at(id) end |
#full_name ⇒ String
The name of the cinema including the brand
107 108 109 |
# File 'lib/cineworld_uk/cinema.rb', line 107 def full_name "#{brand} #{name}" end |
#locality ⇒ String
Uses the standard method naming as at microformats.org/wiki/adr
The locality (town) of the cinema
118 119 120 121 122 123 124 |
# File 'lib/cineworld_uk/cinema.rb', line 118 def locality if adr_has_region? && !adr_in_london? adr_array[-2] else adr_array[-1] end end |
#postal_code ⇒ String
Uses the standard method naming as at microformats.org/wiki/adr
Post code of the cinema
133 134 135 |
# File 'lib/cineworld_uk/cinema.rb', line 133 def postal_code last_adr_line_array[-2..-1] * ' ' end |
#region ⇒ String?
Uses the standard method naming as at microformats.org/wiki/adr
The region (county) of the cinema if provided
144 145 146 |
# File 'lib/cineworld_uk/cinema.rb', line 144 def region last_adr_line_non_postal_code if adr_has_region? && !adr_in_london? end |
#screenings ⇒ Array<CineworldUk::Screening>
All planned screenings
154 155 156 |
# File 'lib/cineworld_uk/cinema.rb', line 154 def screenings Screening.at(id) end |
#street_address ⇒ Object
Uses the standard method naming as at microformats.org/wiki/adr
The street adress of the cinema
165 166 167 |
# File 'lib/cineworld_uk/cinema.rb', line 165 def street_address adr_parts[0] end |