class CineworldUk::Internal::Parser::Api::Performance

Parses a single json hash to produce time details

Public Class Methods

new(data) click to toggle source

@param [Hash] data from one performance @return [CineworldUk::Internal::Parser::Api::Performance]

# File lib/cineworld_uk/internal/parser/api/performance.rb, line 10
def initialize(data)
  @data = data
end

Public Instance Methods

booking_url() click to toggle source

@return [String] direct booking url

# File lib/cineworld_uk/internal/parser/api/performance.rb, line 15
def booking_url
  "http://www.cineworld.co.uk#{@data['url']}"
end
film_id() click to toggle source

@return [Integer] id for film lookup

# File lib/cineworld_uk/internal/parser/api/performance.rb, line 20
def film_id
  @data['film']
end
starting_at() click to toggle source

@return [DateTime] in local time

# File lib/cineworld_uk/internal/parser/api/performance.rb, line 25
def starting_at
  Time.strptime(time_str, '%Y%m%d %H:%S')
end
variant() click to toggle source

@return [Array<String>] includes audio described & subtitled

# File lib/cineworld_uk/internal/parser/api/performance.rb, line 30
def variant
  [
    @data['ad'] ? 'audio_described' : nil,
    @data['subtitled'] ? 'subtitled' : nil
  ].compact
end

Private Instance Methods

time_str() click to toggle source
# File lib/cineworld_uk/internal/parser/api/performance.rb, line 39
def time_str
  "#{@data['date']} #{@data['time']}"
end