class TopBox::Movie
Attributes
metascore[RW]
rating[RW]
review_url[RW]
reviews[RW]
runtime[RW]
summary[RW]
title[RW]
total_gross[RW]
url[RW]
weeks_in_theater[RW]
Public Class Methods
all()
click to toggle source
# File lib/top_box/movie.rb, line 14 def self.all @@all end
new(attribute_hash)
click to toggle source
# File lib/top_box/movie.rb, line 5 def initialize(attribute_hash) @title = attribute_hash[:title] @weeks_in_theater = attribute_hash[:weeks_in_theater] @total_gross = attribute_hash[:total_gross] @url = attribute_hash[:url] @reviews = [] @@all << self end
new_from_collection(movies_attributes_array)
click to toggle source
# File lib/top_box/movie.rb, line 22 def self.new_from_collection(movies_attributes_array) movies_attributes_array.each{ |x| TopBox::Movie.new(x) } end
Public Instance Methods
get_movie_details()
click to toggle source
# File lib/top_box/movie.rb, line 26 def get_movie_details movie_page = Scraper.scrape_movie_page(@url) #'/title/tt3104988' @summary = movie_page.css('.inline.canwrap span')[0].text.strip @metascore = movie_page.css('.metacriticScore').text.strip @rating = movie_page.css('.txt-block span')[0].text.capitalize @runtime = movie_page.css('.txt-block time').text @review_url = movie_page.css('.titleReviewBarSubItem a').attribute('href').value end
get_reviews()
click to toggle source
# File lib/top_box/movie.rb, line 36 def get_reviews if @reviews == [] reviews_array = Scraper.scrape_review_page("#{@url}/#{@review_url}") reviews_array.each do |x| a = TopBox::Review.new(x) @reviews << a end end end
num()
click to toggle source
# File lib/top_box/movie.rb, line 18 def num @@all.index(self)+1 end