class OdeonUk::Performance

The object representing a single screening of a film on the Odeon 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<OdeonUk::Performance>]

# File lib/odeon_uk/performance.rb, line 27
def self.at(cinema_id)
  cinema_id = cinema_id.to_i
  film_ids_at(cinema_id).flat_map do |film_id|
    api_response.film_times(cinema_id, film_id).flat_map do |day|
      performance_days(day).map do |hash|
        new(hash.merge(cinema_hash(cinema_id))
                .merge(film_name: film_name(film_id)))
      end
    end
  end
end

Private Class Methods

api_response() click to toggle source

private

# File lib/odeon_uk/performance.rb, line 53
def self.api_response
  @api_response ||= OdeonUk::Internal::ApiResponse.new
end
cinema_hash(cinema_id) click to toggle source
# File lib/odeon_uk/performance.rb, line 58
def self.cinema_hash(cinema_id)
  { cinema_id: cinema_id, cinema_name: Cinema.new(cinema_id).name }
end
film_ids_at(cinema_id) click to toggle source
# File lib/odeon_uk/performance.rb, line 73
def self.film_ids_at(cinema_id)
  films_at(cinema_id).keys
end
film_lookup() click to toggle source
# File lib/odeon_uk/performance.rb, line 68
def self.film_lookup
  @film_lookup ||= OdeonUk::Internal::Parser::Api::FilmLookup.new
end
film_name(film_id) click to toggle source
# File lib/odeon_uk/performance.rb, line 78
def self.film_name(film_id)
  film_lookup.to_hash[film_id]['title']
end
films_at(cinema_id) click to toggle source
# File lib/odeon_uk/performance.rb, line 63
def self.films_at(cinema_id)
  film_lookup.at(cinema_id)
end
performance_days(data) click to toggle source
# File lib/odeon_uk/performance.rb, line 83
def self.performance_days(data)
  OdeonUk::Internal::Parser::Api::PerformanceDay.new(data).to_a
end