Class: CineworldUk::Screening
- Inherits:
-
Object
- Object
- CineworldUk::Screening
- Defined in:
- lib/cineworld_uk/screening.rb
Overview
The object representing a single screening on the Cineworld UK website
Instance Attribute Summary collapse
-
#booking_url ⇒ String
readonly
The booking URL on the cinema website.
-
#cinema_name ⇒ String
readonly
The cinema name.
-
#dimension ⇒ String
readonly
2d or 3d.
-
#film_name ⇒ String
readonly
The film name.
Class Method Summary collapse
-
.at(cinema_id) ⇒ Array<CineworldUk::Screening>
All currently listed films showing at a cinema.
Instance Method Summary collapse
-
#initialize(options) ⇒ Screening
constructor
A new instance of Screening.
-
#showing_at ⇒ Time
The UTC time of the screening.
-
#showing_on ⇒ Date
The date of the screening.
-
#variant ⇒ Array[String]
The kinds of screening.
Constructor Details
#initialize(options) ⇒ Screening
Returns a new instance of Screening.
21 22 23 24 25 26 27 28 29 |
# File 'lib/cineworld_uk/screening.rb', line 21 def initialize() @booking_url = .fetch(:booking_url, nil) @cinema_name = .fetch(:cinema_name) @cinema_id = .fetch(:cinema_id) @dimension = .fetch(:dimension, '2d') @film_name = .fetch(:film_name) @time = .fetch(:time) @variant = .fetch(:variant, []) end |
Instance Attribute Details
#booking_url ⇒ String (readonly)
Returns the booking URL on the cinema website.
5 6 7 |
# File 'lib/cineworld_uk/screening.rb', line 5 def booking_url @booking_url end |
#cinema_name ⇒ String (readonly)
Returns the cinema name.
9 10 11 |
# File 'lib/cineworld_uk/screening.rb', line 9 def cinema_name @cinema_name end |
#dimension ⇒ String (readonly)
Returns 2d or 3d.
7 8 9 |
# File 'lib/cineworld_uk/screening.rb', line 7 def dimension @dimension end |
#film_name ⇒ String (readonly)
Returns the film name.
11 12 13 |
# File 'lib/cineworld_uk/screening.rb', line 11 def film_name @film_name end |
Class Method Details
.at(cinema_id) ⇒ Array<CineworldUk::Screening>
All currently listed films showing at a cinema
34 35 36 37 38 |
# File 'lib/cineworld_uk/screening.rb', line 34 def self.at(cinema_id) whatson_parser(cinema_id).films_with_screenings.map do |html| create_for_single_film(html, cinema_id) end.flatten end |
Instance Method Details
#showing_at ⇒ Time
The UTC time of the screening
48 49 50 51 52 53 54 55 56 |
# File 'lib/cineworld_uk/screening.rb', line 48 def showing_at @when ||= begin if @time.utc? @time else TZInfo::Timezone.get('Europe/London').local_to_utc(@time) end end end |
#showing_on ⇒ Date
The date of the screening
42 43 44 |
# File 'lib/cineworld_uk/screening.rb', line 42 def showing_on showing_at.to_date end |
#variant ⇒ Array[String]
The kinds of screening
60 61 62 |
# File 'lib/cineworld_uk/screening.rb', line 60 def variant @variant.map(&:downcase).sort end |