Sha256: 383f0b86f79e887f930b53fc9a06912c61710903e58367e5d5da17fbe1f49790

Contents?: true

Size: 851 Bytes

Versions: 6

Compression:

Stored size: 851 Bytes

Contents

module PicturehouseUk
  # @api private
  module Internal
    # Parses a chunk of HTML to derive movie showing data
    class CinemaPage
      # css for a film + screenings
      FILM_CSS = '#events .largelist .item'

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

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

      private

      def cinema
        @cinema ||= PicturehouseUk::Internal::Website.new.cinema(@cinema_id)
      end

      def cinema_doc
        @cinema_doc ||= Nokogiri::HTML(cinema)
      end

      def film_nodes
        cinema_doc.css(FILM_CSS)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
picturehouse_uk-2.0.5 lib/picturehouse_uk/internal/cinema_page.rb
picturehouse_uk-2.0.4 lib/picturehouse_uk/internal/cinema_page.rb
picturehouse_uk-2.0.3 lib/picturehouse_uk/internal/cinema_page.rb
picturehouse_uk-2.0.2 lib/picturehouse_uk/internal/cinema_page.rb
picturehouse_uk-2.0.1 lib/picturehouse_uk/internal/cinema_page.rb
picturehouse_uk-2.0.0 lib/picturehouse_uk/internal/cinema_page.rb