Class: CineworldUk::Internal::ScreeningParser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cineworld_uk/internal/screening_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.

parse a single performance

Constant Summary collapse

DATE_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.

regex for date in url

/date\=(\d{4})(\d{2})(\d{2})/
TIME_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.

regex for time in url

/time\=(\d{2})\:(\d{2})/
DIMENSION_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 selector for dimension

'.icon-service-2d, .icon-service-3d'
BABY_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 selector for baby screening

'.icon-service-cb'
DBOX_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 selector for d-box screening

'.icon-service-dx'
HFR_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 selector for hfr screening

'.icon-service-hfr'
IMAX_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 selector for imax screening

'.icon-service-ix'
KIDS_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 selector for kids screening

'.icon-service-m4j'

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ ScreeningParser

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.

Returns a new instance of ScreeningParser.

Parameters:

  • html (String)

    a chunk of html representing one screening



26
27
28
# File 'lib/cineworld_uk/internal/screening_parser.rb', line 26

def initialize(html)
  @html = html.to_s
end

Instance Method Details

#booking_urlString

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.

url to book this screening

Returns:

  • (String)


32
33
34
35
# File 'lib/cineworld_uk/internal/screening_parser.rb', line 32

def booking_url
  return unless bookable?
  'http://www.cineworld.co.uk' + doc.css('a').attribute('href')
end

#dimensionString

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.

the dimension of the screening

Returns:

  • (String)


39
40
41
42
# File 'lib/cineworld_uk/internal/screening_parser.rb', line 39

def dimension
  return unless bookable?
  doc.css(DIMENSION_CSS).text.downcase
end

#timeTime

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.

utc time of the screening

Returns:

  • (Time)


46
47
48
49
# File 'lib/cineworld_uk/internal/screening_parser.rb', line 46

def time
  return unless bookable?
  timezone.local_to_utc(Time.utc(*date_array + time_array))
end

#to_hashHash

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.

a attributes of a single screening

Examples:

Cineworld::Internal::ScreeningParser.new(html).to_hash
=> {
     booking_url: 'http://...',
     dimension:   '2d',
     time:        <Time>,
     variant:     ['imax']
   }

Returns:

  • (Hash)


71
72
73
74
75
76
77
78
79
# File 'lib/cineworld_uk/internal/screening_parser.rb', line 71

def to_hash
  return unless bookable?
  {
    booking_url: booking_url,
    dimension:   dimension,
    time:        time,
    variant:     variant
  }
end

#variantArray<String>

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.

anything special about the screening

Examples:

Cineworld::Internal::ScreeningParser.new(html).tags
=> ["imax"]

Returns:

  • (Array<String>)


56
57
58
59
# File 'lib/cineworld_uk/internal/screening_parser.rb', line 56

def variant
  return unless bookable?
  [baby, dbox, hfr, imax, kids].compact
end