Sha256: bea2b2042803e2f057c1c174a0ac68674009552c38e00c2eb5d7d81e3bf238a6

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require 'open-uri'
require 'openssl'

module PicturehouseUk
  # @api private
  module Internal
    # fetches pages from the picturehouse.com website
    class Website
      # get the cinema page with showings for passed id
      # @return [String]
      def cinema(id)
        get("cinema/#{id}")
      end

      # get the cinema screenings page for passed id
      # @return [String]
      def whats_on(id)
        get("cinema/#{id}/Whats_On")
      rescue OpenURI::HTTPError
        ''
      end

      # get the cinema contact information page for passed id
      # @return [String]
      def info(id)
        get("cinema/info/#{id}")
      rescue OpenURI::HTTPError
        ''
      end

      # get the home page
      # @return [String]
      def home
        get(nil)
      end

      private

      def get(path)
        # SSL verification doesn't work on picturehouses.com
        open("https://www.picturehouses.com/#{path}",
             ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE).read
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
picturehouse_uk-4.0.0 lib/picturehouse_uk/internal/website.rb
picturehouse_uk-3.0.14 lib/picturehouse_uk/internal/website.rb