Class: LatestTomatoes::Movies
- Inherits:
-
Object
- Object
- LatestTomatoes::Movies
- Defined in:
- lib/latest_tomatoes_cli_gem/movies.rb
Instance Attribute Summary collapse
-
#actors ⇒ Object
Returns the value of attribute actors.
-
#mpaaRating ⇒ Object
Returns the value of attribute mpaaRating.
-
#synopsis ⇒ Object
Returns the value of attribute synopsis.
-
#title ⇒ Object
Returns the value of attribute title.
-
#tomatoScore ⇒ Object
Returns the value of attribute tomatoScore.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Attribute Details
#actors ⇒ Object
Returns the value of attribute actors.
2 3 4 |
# File 'lib/latest_tomatoes_cli_gem/movies.rb', line 2 def actors @actors end |
#mpaaRating ⇒ Object
Returns the value of attribute mpaaRating.
2 3 4 |
# File 'lib/latest_tomatoes_cli_gem/movies.rb', line 2 def mpaaRating @mpaaRating end |
#synopsis ⇒ Object
Returns the value of attribute synopsis.
2 3 4 |
# File 'lib/latest_tomatoes_cli_gem/movies.rb', line 2 def synopsis @synopsis end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/latest_tomatoes_cli_gem/movies.rb', line 2 def title @title end |
#tomatoScore ⇒ Object
Returns the value of attribute tomatoScore.
2 3 4 |
# File 'lib/latest_tomatoes_cli_gem/movies.rb', line 2 def tomatoScore @tomatoScore end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/latest_tomatoes_cli_gem/movies.rb', line 2 def url @url end |
Class Method Details
.latest ⇒ Object
4 5 6 |
# File 'lib/latest_tomatoes_cli_gem/movies.rb', line 4 def self.latest self.scrape_movies end |
.scrape_movies ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/latest_tomatoes_cli_gem/movies.rb', line 8 def self.scrape_movies movies = [] doc = Nokogiri::HTML(open("http://d3biamo577v4eu.cloudfront.net/api/private/v1.0/m/list/find?page=1&limit=30&type=dvd-new-releases&services=amazon%3Bamazon_prime%3Bflixster%3Bhbo_go%3Bitunes%3Bnetflix_iw%3Bvudu&sortBy=release")) jsonstring = doc.search("p").text # gets json string from main html element x=JSON.parse(jsonstring) #parsed array/hash of movie data x["results"].each do |movie| movies << { :title => movie["title"], :tomatoScore => movie["tomatoScore"], :actors => movie["actors"], :mpaaRating => movie["mpaaRating"], :synopsis => movie["synopsis"], :url => movie["url"] } end movies end |