Sha256: 1c5585baac88508be6ee37aee05edd94a08825583142cb9a421bd448b6d78541
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
module Fandango module TheaterShowtimes BASE_URL = 'http://www.fandango.com/theater_%{theater_id}/theaterpage?date=%{date}' module_function def call(showtimes_link) response = request(showtimes_link) raise BadResponse.new(response) unless response.status.first == '200' html = response.read Parser.(html) end def by_id_and_date(theater_id:, date: Date.today) url = BASE_URL % {:theater_id => theater_id, :date => date} call url end def request(showtimes_link) open(showtimes_link) end module Parser module_function def call(html) doc = Nokogiri.HTML(html) doc.css('.showtimes-movie-container').map do |movie_node| movie = Movie.parse(movie_node) movie[:showtimes] = movie_node.at_css('.showtimes-times').css('a').map do |showtime_node| Showtime.parse(showtime_node) end movie end end end end class BadResponse < API::BadResponse; end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fandango-2.0.0 | lib/fandango/api/theater_showtimes.rb |