class OdeonUk::Internal::Parser::Api::PerformanceDay
A single day of performances for a particular film
Constants
- TimeParser
parse a time to utc time
Public Class Methods
new(data)
click to toggle source
# File lib/odeon_uk/internal/parser/api/performance_day.rb, line 8 def initialize(data) @data = data end
Public Instance Methods
to_a()
click to toggle source
# File lib/odeon_uk/internal/parser/api/performance_day.rb, line 12 def to_a performance_kinds.each_with_index.flat_map do |_, index| starting_times(index).map do |time| { dimension: dimension(index), starting_at: TimeParser.new(date, time).to_utc, variant: variant(index) } end end end
Private Instance Methods
date()
click to toggle source
# File lib/odeon_uk/internal/parser/api/performance_day.rb, line 26 def date @data['date'] end
dimension(index)
click to toggle source
# File lib/odeon_uk/internal/parser/api/performance_day.rb, line 30 def dimension(index) performance_kind(index).include?('3D') ? '3d' : '2d' end
performance_kind(index)
click to toggle source
# File lib/odeon_uk/internal/parser/api/performance_day.rb, line 38 def performance_kind(index) performance_kinds[index]['attribute'] end
performance_kinds()
click to toggle source
# File lib/odeon_uk/internal/parser/api/performance_day.rb, line 34 def performance_kinds @data['attributes'] end
starting_times(index)
click to toggle source
# File lib/odeon_uk/internal/parser/api/performance_day.rb, line 42 def starting_times(index) performance_kinds[index]['showtimes'][0].map do |h| h['performanceTime'] end end
variant(index)
click to toggle source
# File lib/odeon_uk/internal/parser/api/performance_day.rb, line 48 def variant(index) { 'Culture' => 'arts', 'Kids' => 'kids', 'IMAX' => 'imax', 'Newbies' => 'baby', 'Silver Cinema' => 'senior' }.select { |k, _| performance_kind(index).include?(k) }.values.uniq end