Class: PicturehouseUk::Internal::AddressParser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/picturehouse_uk/internal/address_parser.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Parses a chunk of HTML to derive address

Constant Summary collapse

ADDRESS_LINES_CSS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

CSS for address lines

'.cinemaListBox'
POSTCODE_REGEX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

regular expression for postal code

/[A-Z]{1,2}\d{1,2}[A-Z]?\s\d{1,2}[A-Z]{1,2}/

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ PicturehouseUk::Internal::AddressParser

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • node (String)

    the HTML to parse into an address



14
15
16
# File 'lib/picturehouse_uk/internal/address_parser.rb', line 14

def initialize(html)
  @html = html
end

Instance Method Details

#addressHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Uses the address naming from microformats.org/wiki/adr

:postal_code, :country

Returns:

  • (Hash)

    contains :street_address, :extended_address, :locality,



21
22
23
24
25
26
27
28
29
# File 'lib/picturehouse_uk/internal/address_parser.rb', line 21

def address
  {
    street_address: array[0],
    extended_address: array.length > 3 ? array[1] : nil,
    locality: array[-2],
    postal_code: array[-1],
    country: 'United Kingdom'
  }
end