class NewYorkFilms::FilmFinder

Public Class Methods

all() click to toggle source
# File lib/new_york_films/film_finder.rb, line 14
def self.all
  @@all_films
end
scraper() click to toggle source

def check_if_provided(css)

return css.text unless css == nil then "not provided"

end

# File lib/new_york_films/film_finder.rb, line 22
def self.scraper
  doc = Nokogiri::HTML(open("http://www.screenslate.com/"))

  doc.search("ul li.screenings__venue___2EEUR li.screenings__screening___2wxaa").map do |film|
    @@all_films << screening = NewYorkFilms::Screening.new

      # screening.theater = check_if_provided(film.parent.parent.css("h3"))
      # screening.title = check_if_provided()

      if film.parent.parent.css("h3") != nil
        screening.theater = film.parent.parent.css("h3").text
      else
        screening.theater = "not provided"
      end

      if film.css("a.screening__link___1rTIP") != nil
        screening.title = film.css("a.screening__link___1rTIP").text
      else
        screening.title = "not provided"
      end


      if film.search("div.screening__details___2yckE span")[0] != nil
        screening.director = film.search("div.screening__details___2yckE span")[0].text
      else
        screening.director = "Not listed."
      end

      if film.search("div.screening__details___2yckE span")[1] != nil
        screening.year = film.search("div.screening__details___2yckE span")[1].text
      else
        screening.year = "not provided"
      end

      if film.search("div.screening__details___2yckE span")[2] != nil
        screening.length = film.search("div.screening__details___2yckE span")[2].text
      else
        screening.length = "not provided"
      end

      if film.search("div.screening__showtimespacing___17fBg span.screening__showtime___3oJD6") != nil
        screening.times = film.search("div.screening__showtimespacing___17fBg span.screening__showtime___3oJD6").text.gsub("pm","pm  ").gsub("am", "am  ")
      else
        screening.times = "not provided"
      end

      if film.search("a.screening__link___1rTIP").attribute('href') == nil
            film.attribute('href').value = "http://www.screenslate.com/"
      end

      screening.website = film.search("a.screening__link___1rTIP").attribute("href").value

      contact = film.parent.parent.css("a").attribute("href").value
      venue = Nokogiri::HTML(open("http://www.screenslate.com#{contact}"))

      if venue.css("div.venue__info___2bLnH p") != nil
        screening.location = venue.css("div.venue__info___2bLnH p").first.text.gsub("Location ", "") if venue.css("div.venue__info___2bLnH p").first.text.include?(", NY")
        if venue.css("div.venue__info___2bLnH p")[1]
          screening.location = venue.css("div.venue__info___2bLnH p")[1].text.gsub("Location ", "") if venue.css("div.venue__info___2bLnH p")[1].text.include?(", NY")
        end
      else
        screening.location = "please see theater's website."
      end
    end
  end
theater_scraper() click to toggle source
# File lib/new_york_films/film_finder.rb, line 88
def self.theater_scraper
  doc = Nokogiri::HTML(open("http://www.screenslate.com/"))
  doc.search("ul li.screenings__venue___2EEUR li.screenings__screening___2wxaa").each do |film|
    @@theaters << film.parent.parent.css("h3").text
  end
  @@theaters
end
theaters() click to toggle source
# File lib/new_york_films/film_finder.rb, line 10
def self.theaters
  @@theaters
end