Sha256: 45f0ba36ee6d42ef21693f24153bb78ad2f44e579a904b89143229b2230301cb

Contents?: true

Size: 936 Bytes

Versions: 5

Compression:

Stored size: 936 Bytes

Contents

module OdeonUk
  # Internal utility classes: Do not use
  # @api private
  module Internal
    # Parses a chunk of HTML to derive showing data for a single films
    class ShowtimesPage
      # css selector for film html chunks
      FILM_CSS = '.film-detail'

      # @param [Integer] cinema_id cineworld cinema id
      def initialize(cinema_id)
        @cinema_id = cinema_id
      end

      # break up the showtimes page into individual chunks for each film
      # @return [Array<String>] html chunks for a film and it's screenings
      def to_a
        film_nodes.map { |node| node.to_s.gsub(/^\s+/, '') }
      end

      private

      def film_nodes
        @film_nodes ||= showtimes_doc.css(FILM_CSS)
      end

      def showtimes
        @showtimes ||= OdeonUk::Internal::Website.new.showtimes(@cinema_id)
      end

      def showtimes_doc
        @showtimes_doc ||= Nokogiri::HTML(showtimes)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
odeon_uk-2.0.4 lib/odeon_uk/internal/showtimes_page.rb
odeon_uk-2.0.3 lib/odeon_uk/internal/showtimes_page.rb
odeon_uk-2.0.2 lib/odeon_uk/internal/showtimes_page.rb
odeon_uk-2.0.1 lib/odeon_uk/internal/showtimes_page.rb
odeon_uk-2.0.0 lib/odeon_uk/internal/showtimes_page.rb