Module: Fandango::TheaterShowtimes

Defined in:
lib/fandango/api/theater_showtimes.rb

Defined Under Namespace

Modules: Parser

Constant Summary collapse

BASE_URL =
'http://www.fandango.com/theater_%{theater_id}/theaterpage?date=%{date}'

Class Method Summary collapse

Class Method Details

.by_id_and_date(theater_id:, date: Date.today) ⇒ Object



16
17
18
19
# File 'lib/fandango/api/theater_showtimes.rb', line 16

def by_id_and_date(theater_id:, date: Date.today)
  url = BASE_URL % {:theater_id => theater_id, :date => date}
  call url
end

.call(showtimes_link) ⇒ Object

Raises:



8
9
10
11
12
13
14
# File 'lib/fandango/api/theater_showtimes.rb', line 8

def call(showtimes_link)
  response = request(showtimes_link)
  raise BadResponse.new(response) unless response.status.first == '200'

  html = response.read
  Parser.(html)
end

.request(showtimes_link) ⇒ Object



21
22
23
# File 'lib/fandango/api/theater_showtimes.rb', line 21

def request(showtimes_link)
  open(showtimes_link)
end