Class: TopMovies::Movie
- Inherits:
-
Object
- Object
- TopMovies::Movie
- Defined in:
- lib/top_movies/movie.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#site ⇒ Object
Returns the value of attribute site.
-
#url ⇒ Object
Returns the value of attribute url.
-
#year ⇒ Object
Returns the value of attribute year.
Class Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/top_movies/movie.rb', line 2 def name @name end |
#site ⇒ Object
Returns the value of attribute site.
2 3 4 |
# File 'lib/top_movies/movie.rb', line 2 def site @site end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/top_movies/movie.rb', line 2 def url @url end |
#year ⇒ Object
Returns the value of attribute year.
2 3 4 |
# File 'lib/top_movies/movie.rb', line 2 def year @year end |
Class Method Details
.all_time ⇒ Object
4 5 6 7 8 |
# File 'lib/top_movies/movie.rb', line 4 def self.all_time #return top movies of this year self.scrape_movies end |
.scrape_imdb ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/top_movies/movie.rb', line 18 def self.scrape_imdb movie = self.new movie.site = "IMDB" doc = Nokogiri::HTML(open("http://www.imdb.com/chart/top")) movie.name = doc.search("tr td")[1].children.children.first.text movie.year = doc.search("tr td")[1].children[3].children.text movie.url = doc.search("tr td")[1].children[1].attributes.first.last.value movie end |
.scrape_movies ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/top_movies/movie.rb', line 10 def self.scrape_movies deals = [] deals << self.scrape_imdb deals << self.scrape_rotten_tomatoes deals end |
.scrape_rotten_tomatoes ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/top_movies/movie.rb', line 29 def self.scrape_rotten_tomatoes movie = self.new movie.site = "Rotten Tomatoes" doc = Nokogiri::HTML(open("https://www.rottentomatoes.com/top/bestofrt/")) movie.name, movie.year = doc.search("tr td")[28].children.children.text.split("\n ")[1] movie.url = "www.rottentomatoes.com"+doc.search("tr td")[28].children[1].attributes.first.last.value movie end |