class CineworldUk::Internal::Parser::Api::CinemaAddress
Parses a string to derive address
Public Class Methods
new(id)
click to toggle source
@param [Integer] id the cinema id @return [CineworldUk::Internal::Parser::Api::CinemaAddress]
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 10 def initialize(id) @id = id end
Public Instance Methods
to_hash()
click to toggle source
@return [Hash] contains :street_address, :extended_address, :locality, :postal_code, :country @note Uses the address naming from microformats.org/wiki/adr
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 17 def to_hash { street_address: street_address, extended_address: extended_address, locality: locality, region: region, postal_code: postal_code, country: 'United Kingdom'.freeze } end
Private Instance Methods
adr_array()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 30 def adr_array @adr_array ||= cinema_detail_hash['address'].split(',').map(&:strip).compact end
cinema_detail_hash()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 35 def cinema_detail_hash @cinema_detail_hash ||= JSON.parse(cinema_detail_response)['cinema'] end
cinema_detail_response()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 39 def cinema_detail_response @cinema_detail_response ||= CineworldUk::Internal::ApiResponse.new.cinema_detail(@id) end
ext_array()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 44 def ext_array @ext_array ||= adr_array[1..-1] end
extended_address()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 48 def extended_address return nil if ext_array.count == 1 london? ? nil : ext_array[0] end
final()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 53 def final @final ||= ext_array.last end
locality()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 57 def locality return ext_array[0] if ext_array.count == 1 london? ? ext_array[0] : ext_array[1] end
london?()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 62 def london? final == 'London' end
postal_code()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 66 def postal_code cinema_detail_hash['postcode'] end
region()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 70 def region 'London' if london? end
street_address()
click to toggle source
# File lib/cineworld_uk/internal/parser/api/cinema_address.rb, line 74 def street_address adr_array[0] end