class NowShowing::Show

Attributes

about[RW]
gross[RW]
metascore[RW]
name[RW]
weekend[RW]

Public Class Methods

all() click to toggle source
# File lib/now_showing/showing.rb, line 32
def self.all
  @@all
end
more_info(movie) click to toggle source

scrapes movie page for addtional movie info

# File lib/now_showing/showing.rb, line 41
def self.more_info(movie)
  doc = Nokogiri::HTML(open(movie.link))
  movie.about = doc.css('.summary_text').text.gsub("\n",' ').squeeze(' ')
  movie.metascore = doc.css('.metacriticScore').text.gsub("\n",' ').squeeze(' ')
end
new(name,weekend,gross,link,about=nil,metascore=nil) click to toggle source
# File lib/now_showing/showing.rb, line 7
def initialize(name,weekend,gross,link,about=nil,metascore=nil)
  @name=name
  @weekend=weekend
  @gross=gross
  @link=link
  @about=about
  @metascore=metascore
  @@all << self
end
reset() click to toggle source
# File lib/now_showing/showing.rb, line 36
def self.reset
  self.all.clear
end
scrape_now_showing() click to toggle source
# File lib/now_showing/showing.rb, line 17
def self.scrape_now_showing
  doc = Nokogiri::HTML(open("http://www.imdb.com/chart/boxoffice?ref_=nv_ch_cht_1 "))
  doc.css("#boxoffice").css('tr').each do |movie|
    #checks if the table row contains movie info
    if movie.css('.ratingColumn')[0] && movie.css('.titleColumn') && movie.css('.ratingColumn')[1]
      name = movie.css('.titleColumn').text.gsub("\n",' ').squeeze(' ')
      weekend = movie.css('.ratingColumn')[0].text.gsub("\n",' ').squeeze(' ')
      gross = movie.css('.ratingColumn')[1].text.gsub("\n",' ').squeeze(' ')
      link="http://www.imdb.com#{movie.css(".posterColumn").css('td')[0].css('a')[0]['href']}"
      self.new(name,weekend,gross,link)
    end
  end
end