MovieJSON Wrapper

Readme Homework


Episode 2 - Movie JSON

A simple API wrapper around the RottenTomato's service

Panda Level

  1. Fix the code where it does not "blow up" when searching for a non-existent movie
  2. Fill in the Api "empty search" code to help with the not found movie

Example:

expect {
  Api.search_by_title("NOTHINGFOUNDHERE")
}.to_not raise_error

Tiger Level

  1. Keep track of the searches a user enters
  2. Reword the question to "Add a movie you really like"
  3. Display the average movie Rating.. Hint

A sample way to do this:

movies = []
movies << Api.search_by_title(movie_title)

Eagle Level

  1. Tiger Level, plus display the average year for the ratings for the movie selected
  2. Calculate the slope of the average ratings from the first year to the last year
  3. Determine if the user is getting happier or madder (slope of line increasing or decreasing)

Slope of line is (y1 - y2) / (x1 - x2) ... In this case, if my average rating for 1990 was 50 and 2012 was 45:

(45 - 50).to_f / (2012 - 1990).to_f
=> -0.22727272727272727  
# getting madder

Copyright: Jesse Wolgamott, MIT License (See LICENSE)

MovieJSON Wrapper

  • Area:

    Databases  
  • Runtime:

    58  
  • Tech:

    JSON API  
  • Tags:

    json movie api  

Many websites have a JSON feed, and being able to wrap them in a Ruby object model is valuable, both for hacking and for integrating with websites of your own.

We will use an API to do movie searches, and try to use that data to tell if we're happier with movies, or unhappier (over time).

We introduce the concept of Structs and OpenStructs here.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

ABOUT RUBY OFF RAILS

Ruby Off Rails is dedicated to accelerating the mastering of Ruby and increasing developer happiness everywhere.

In my software training, I see two distinct sets of programmers: those who know Ruby, and those who haven’t learned it yet. People who learn Ruby have an easier time understanding Rails, gems, and what magic voodoo is going on. And most importantly, they can cast wicked voodoo themselves.