Sha256: daaf585b217ab74809f5c5c18d650acd9ceb67c84dc2a74c587598c1c18abc3c

Contents?: true

Size: 979 Bytes

Versions: 7

Compression:

Stored size: 979 Bytes

Contents

module OdeonUk
  # Internal utility classes: Do not use
  # @api private
  module Html
    # The object representing a single screening of a film on the Odeon UK website
    class Screenings
      # css selector for film html chunks
      FILM_CSS = '.film-detail'

      # All currently listed films showing at a cinema
      # @param [Integer] cinema_id id of the cinema on the website
      # @return [Array<Hash>]
      def self.at(cinema_id)
        film_nodes(cinema_id).flat_map do |node|
          screenings_parser(node).to_a
        end
      end

      private

      def self.screenings_parser(html)
        Parser::FilmWithScreenings.new(html)
      end

      def self.film_nodes(id)
        showtimes_doc(id).css(FILM_CSS).map { |node| node.to_s.gsub(/^\s+/, '') }
      end

      def self.showtimes(id)
        OdeonUk::Html::Website.new.showtimes(id)
      end

      def self.showtimes_doc(id)
        Nokogiri::HTML(showtimes(id))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
odeon_uk-3.0.6 lib/odeon_uk/html/screenings.rb
odeon_uk-3.0.5 lib/odeon_uk/html/screenings.rb
odeon_uk-3.0.4 lib/odeon_uk/html/screenings.rb
odeon_uk-3.0.3 lib/odeon_uk/html/screenings.rb
odeon_uk-3.0.2 lib/odeon_uk/html/screenings.rb
odeon_uk-3.0.1 lib/odeon_uk/html/screenings.rb
odeon_uk-3.0.0 lib/odeon_uk/html/screenings.rb