class NowShowing::Opening

Attributes

about[RW]
metascore[RW]
name[RW]

Public Class Methods

all() click to toggle source
# File lib/now_showing/opening.rb, line 30
def self.all
  @@all
end
new(name,about,metascore) click to toggle source
# File lib/now_showing/opening.rb, line 7
def initialize(name,about,metascore)
  @name=name
  @about=about
  @metascore=metascore
  @@all << self
end
reset() click to toggle source
# File lib/now_showing/opening.rb, line 34
def self.reset
  self.all.clear
end
scrape() click to toggle source
# File lib/now_showing/opening.rb, line 14
def self.scrape
  doc = Nokogiri::HTML(open("http://www.imdb.com/movies-in-theaters/"))
  doc.css(".list_item").each do |movie|
    name = movie.css(".overview-top").css('h4').text.split(" ")[0..-2].join(" ")
    about = movie.css('.outline').text.strip
    metascore = movie.css('.metascore').text.strip
    metascore = "Metacritic score not yet available" if metascore == ""
    self.new(name,about,metascore)

  end
  #remove last ten form list which are the weeks top ten

  @@all = @@all[0..-11]
end