class PicturehouseUk::Internal::Parser::Screenings
Parses screenings page into an array of hashes for an individual cinema
Constants
- DATE
- LISTINGS
css for a day of films & screenings
Public Class Methods
new(cinema_id)
click to toggle source
# File lib/picturehouse_uk/internal/parser/screenings.rb, line 12 def initialize(cinema_id) @cinema_id = cinema_id end
Public Instance Methods
to_a()
click to toggle source
parse the cinema page into an array of screenings attributes @return [Array<Hash>]
# File lib/picturehouse_uk/internal/parser/screenings.rb, line 18 def to_a doc.css(LISTINGS).flat_map do |node| FilmWithShowtimes.new(node, date_from_html(node.css(DATE).to_s)).to_a end end
Private Instance Methods
date_from_html(html)
click to toggle source
# File lib/picturehouse_uk/internal/parser/screenings.rb, line 27 def date_from_html(html) if html =~ /listings-further-ahead-today/ Date.now else html.match(/listings-further-ahead-(\d{4})(\d{2})(\d{2})/) do |m| Date.new(m[1].to_i, m[2].to_i, m[3].to_i) end end end
doc()
click to toggle source
# File lib/picturehouse_uk/internal/parser/screenings.rb, line 37 def doc @doc ||= Nokogiri::HTML(page) end
page()
click to toggle source
# File lib/picturehouse_uk/internal/parser/screenings.rb, line 41 def page @page ||= PicturehouseUk::Internal::Website.new.whats_on(@cinema_id) end