class CineworldUk::Performance
The object representing a single screening on the Cineworld UK website
Public Class Methods
at(cinema_id)
click to toggle source
All currently listed films showing at a cinema @param [Integer] cinema_id id of the cinema on the website @return [Array<CineworldUk::Screening>]
# File lib/cineworld_uk/performance.rb, line 28 def self.at(cinema_id) cinema_id = cinema_id.to_i dates(cinema_id).flat_map do |date| performances_on(cinema_id, date).flat_map do |p| new cinema_hash(cinema_id).merge(p) end end end
Private Class Methods
api()
click to toggle source
@api private
# File lib/cineworld_uk/performance.rb, line 52 def self.api @api ||= Internal::ApiResponse.new end
cinema_hash(cinema_id)
click to toggle source
@api private
# File lib/cineworld_uk/performance.rb, line 58 def self.cinema_hash(cinema_id) { cinema_id: cinema_id, cinema_name: CineworldUk::Cinema.new(cinema_id).name } end
dates(cinema_id)
click to toggle source
@api private
# File lib/cineworld_uk/performance.rb, line 67 def self.dates(cinema_id) @dates ||= JSON.parse(api.dates(cinema_id))['dates'].map do |str| Date.strptime(str, '%Y%m%d') end end
films()
click to toggle source
@api private
# File lib/cineworld_uk/performance.rb, line 75 def self.films @films ||= Internal::Parser::Api::FilmLookup.new.to_hash end
performances_on(cinema_id, date)
click to toggle source
# File lib/cineworld_uk/performance.rb, line 80 def self.performances_on(cinema_id, date) Internal::Parser::Api::PerformancesByDay.new(cinema_id, date, films).to_a end