class CineworldUk::Internal::Parser::Api::PerformancesByDay
A day of performances, a parser for a single API call
Public Class Methods
new(cinema_id, date, film_lookup)
click to toggle source
# File lib/cineworld_uk/internal/parser/api/performances_by_day.rb, line 8 def initialize(cinema_id, date, film_lookup) @cinema_id = cinema_id @date = date @film_lookup = film_lookup end
Public Instance Methods
to_a()
click to toggle source
Details of performance from single day @return [Array<Hash>] :booking_url, :dimension, :film_name, :starting_at, :variant
# File lib/cineworld_uk/internal/parser/api/performances_by_day.rb, line 17 def to_a performances.map do |performance| film = @film_lookup[performance.film_id] { booking_url: performance.booking_url, dimension: film.dimension, film_name: film.name, starting_at: utc(performance.starting_at), variant: (performance.variant + film.variant).sort } end end
Private Instance Methods
parsed_response()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/performances_by_day.rb, line 38 def parsed_response JSON.parse(response)['performances'] end
performances()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/performances_by_day.rb, line 32 def performances parsed_response.map do |hash| Internal::Parser::Api::Performance.new(hash) end end
response()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/performances_by_day.rb, line 42 def response Internal::ApiResponse.new.performances(@cinema_id, @date) end
utc(time)
click to toggle source
# File lib/cineworld_uk/internal/parser/api/performances_by_day.rb, line 46 def utc(time) time if time.utc? TZInfo::Timezone.get('Europe/London').local_to_utc(time) end