Class: CineworldUk::Internal::FilmWithScreeningsParser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cineworld_uk/internal/film_with_screenings_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 movie showing data

Constant Summary collapse

FILM_NAME_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 film name

'h3.h1 a[href*=whatson]'
PERFORMANCES_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 performances

'.schedule .performances > li'

Instance Method Summary collapse

Constructor Details

#initialize(film_html) ⇒ FilmWithScreeningsParser

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

Parameters:

  • film_html (String)

    a chunk of html



13
14
15
# File 'lib/cineworld_uk/internal/film_with_screenings_parser.rb', line 13

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

Instance Method Details

#cinema_idString

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 cinema id

Returns:

  • (String)


19
20
21
# File 'lib/cineworld_uk/internal/film_with_screenings_parser.rb', line 19

def cinema_id
  name_doc.to_s.match(/cinema=(\d+)/)[1].to_i
end

#film_nameString

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 film name

Returns:

  • (String)


25
26
27
# File 'lib/cineworld_uk/internal/film_with_screenings_parser.rb', line 25

def film_name
  name_doc.children[0].to_s
end

#to_aArray<Hash>

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.

attributes of all the screenings

Returns:

  • (Array<Hash>)


31
32
33
34
35
36
# File 'lib/cineworld_uk/internal/film_with_screenings_parser.rb', line 31

def to_a
  performances_doc.map do |node|
    next unless screening_parser_hash(node)
    screening_parser_hash(node).merge(film_hash)
  end.compact
end