From 745009b453fa9eb53990e217f3f0b89b81270107 Mon Sep 17 00:00:00 2001 From: drammopo Date: Wed, 19 Feb 2014 23:17:40 +0200 Subject: [PATCH 01/23] Panda Level complete. --- movie_json.rb | 14 +++++++++----- spec/api_spec.rb | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/movie_json.rb b/movie_json.rb index d8a91d7..6abf89a 100644 --- a/movie_json.rb +++ b/movie_json.rb @@ -2,16 +2,20 @@ require_relative "lib/api" def find_movie - puts "OH HAI. Search?" - movie_title = gets - movie = Api.search_by_title(movie_title) - puts "Found: #{movie.title}. Score: #{movie.score}" + begin + puts "OH HAI. Search?" + movie_title = gets + movie = Api.search_by_title(movie_title) + puts "Found: #{movie.title}. Score: #{movie.score}" + rescue NoMethodError + puts "Not found." + end end find_movie while true do - puts "Search Again (Y/N)" + puts "Search Again (Y/N)" answer = gets.upcase[0] if answer == "Y" find_movie diff --git a/spec/api_spec.rb b/spec/api_spec.rb index 9014106..ac5da10 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -24,4 +24,8 @@ it "should return the year" do movie.year.should eq(1994) end + + it "should not raise an error when searching for a non-existent movie" do + expect { Api.search_by_title("NOTHINGFOUNDHERE") }.to_not raise_error + end end From c7a7953e6ac1338bb13d7dfdc8ca4bc72d91ce8a Mon Sep 17 00:00:00 2001 From: drammopo Date: Wed, 19 Feb 2014 23:21:03 +0200 Subject: [PATCH 02/23] Added unrefactored Tiger Level. --- movie_json.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/movie_json.rb b/movie_json.rb index 6abf89a..939b293 100644 --- a/movie_json.rb +++ b/movie_json.rb @@ -1,24 +1,32 @@ require_relative "lib/movie" require_relative "lib/api" +def average_movie_rating(movies_array) + movies_array.inject(0.0) { |sum, movie| sum + movie.score } / movies_array.size +end + def find_movie begin - puts "OH HAI. Search?" + puts "OH HAI. Add a movie you really like?" movie_title = gets movie = Api.search_by_title(movie_title) - puts "Found: #{movie.title}. Score: #{movie.score}" + @movies << movie + puts "Added: #{movie.title}. Score: #{movie.score}" rescue NoMethodError puts "Not found." end end +@movies = [] find_movie +puts "The average rating is #{average_movie_rating(@movies)}." while true do puts "Search Again (Y/N)" answer = gets.upcase[0] if answer == "Y" find_movie + puts "The average rating is #{average_movie_rating(@movies)}." else break end From 0c115b45484098d50b1e1d4fe9124d13bd874d27 Mon Sep 17 00:00:00 2001 From: drammopo Date: Wed, 19 Feb 2014 23:36:24 +0200 Subject: [PATCH 03/23] Added refactored Tiger Level. --- lib/api.rb | 2 +- lib/movie.rb | 16 ++++++++++++++++ movie_json.rb | 10 ++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/api.rb b/lib/api.rb index a8d499c..8bf736d 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -9,7 +9,7 @@ class Api def self.search_by_title(title) url = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=#{APIKEY}&q=#{URI.encode(title)}&page_limit=1" struct = OpenStruct.new(get_url_as_json(url).fetch("movies").first) - Movie.new(id: struct.id.to_i, + Movie.build(id: struct.id.to_i, title: struct.title, year: struct.year, score: struct.ratings["critics_score"] diff --git a/lib/movie.rb b/lib/movie.rb index 167a23e..c05529d 100644 --- a/lib/movie.rb +++ b/lib/movie.rb @@ -1,5 +1,6 @@ class Movie + @@movies = [] attr_reader :id, :title, :year, :score def initialize(hash={}) @id = hash.fetch(:id) @@ -7,4 +8,19 @@ def initialize(hash={}) @year = hash.fetch(:year) @score = hash.fetch(:score) end + + def self.build(args) + movie = Movie.new(args) + @@movies << movie + movie + end + + def self.average_rating + @@movies.inject(0.0) { |sum, movie| sum + movie.score } / @@movies.size + end + + def self.all_movies + @@movies + end + end diff --git a/movie_json.rb b/movie_json.rb index 939b293..5c93685 100644 --- a/movie_json.rb +++ b/movie_json.rb @@ -1,32 +1,26 @@ require_relative "lib/movie" require_relative "lib/api" -def average_movie_rating(movies_array) - movies_array.inject(0.0) { |sum, movie| sum + movie.score } / movies_array.size -end - def find_movie begin puts "OH HAI. Add a movie you really like?" movie_title = gets movie = Api.search_by_title(movie_title) - @movies << movie puts "Added: #{movie.title}. Score: #{movie.score}" rescue NoMethodError puts "Not found." end end -@movies = [] find_movie -puts "The average rating is #{average_movie_rating(@movies)}." +puts "The average rating is #{Movie.average_rating}." while true do puts "Search Again (Y/N)" answer = gets.upcase[0] if answer == "Y" find_movie - puts "The average rating is #{average_movie_rating(@movies)}." + puts "The average rating is #{Movie.average_rating}." else break end From 8df31e7a632ab5095c10cbe7123fae0615bec0d3 Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 20 Feb 2014 00:47:46 -0800 Subject: [PATCH 04/23] Added RSpec file as #expect syntax was failing. Movie.average_rating working. --- lib/movie.rb | 6 +++++- spec/movie_spec.rb | 52 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/lib/movie.rb b/lib/movie.rb index c05529d..9d27ffc 100644 --- a/lib/movie.rb +++ b/lib/movie.rb @@ -16,7 +16,11 @@ def self.build(args) end def self.average_rating - @@movies.inject(0.0) { |sum, movie| sum + movie.score } / @@movies.size + all_movies.inject(0.0) { |sum, movie| sum + movie.score } / all_movies.size + end + + def self.count + @@movies.count end def self.all_movies diff --git a/spec/movie_spec.rb b/spec/movie_spec.rb index 088bd37..14c5102 100644 --- a/spec/movie_spec.rb +++ b/spec/movie_spec.rb @@ -1,12 +1,50 @@ +require 'rspec' require_relative "../lib/movie" describe Movie do - it "should store the title, year, and score" do - movie = Movie.new(id: "the-id", title: "the-title", year: 1998, score: 50) - movie.id.should eq("the-id") - movie.title.should eq("the-title") - movie.year.should eq(1998) - movie.score.should eq(50) + describe "#new" do + + let (:movie){Movie.new(id: "the-id", title: "the-title", year: 1998, score: 50)} + + it "should store the title, year, and score" do + movie.id.should eq("the-id") + movie.title.should eq("the-title") + movie.year.should eq(1998) + movie.score.should eq(50) + end + + it 'should inherit from vehicle' do + movie.is_a?(Movie).should be_true + end + + it 'should not change the movie count' do + Movie.count.should eq(0) + end + end + + describe ".build" do + + it "records the movie when I build it" do + movie = Movie.build(id: 10020, title: 'Pirates of the Caribbean: The Curse of the Black Pearl', year: 2003, score: 79) + expect(Movie.all_movies).to include (movie) + end + + it "should increment the movie count" do + expect{Movie.build(id: 10036, title: 'Forrest Gump', year: 1994, score: 71)}.to change{Movie.count}.from(1).to(2) + end + end + + describe ".average_rating" do + it "should have no average rating initially" do + #how do you mock this scenario + end + + it 'should calculate the average rating while ignoring the Movie#build calls above' do + #how do you change scope for RSpec object. Or rather how do you reset the Movie object instance variables? + end + + it "should calculate the average rating for Forrest Gump and Pirates of the...as 75 " do + Movie.average_rating.should eq(75) + end end - end From ccfed8f1fae86a6bace4579d3e8210d9caad2c2e Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 20 Feb 2014 00:56:55 -0800 Subject: [PATCH 05/23] Added Gemfiles. --- Gemfile | 4 ++++ Gemfile.lock | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Gemfile create mode 100644 Gemfile.lock diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..0854d37 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source 'http://rubygems.org' + + +gem 'rspec' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..ea5be4a --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,18 @@ +GEM + remote: http://rubygems.org/ + specs: + diff-lcs (1.2.5) + rspec (2.14.1) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + rspec-core (2.14.7) + rspec-expectations (2.14.5) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.5) + +PLATFORMS + ruby + +DEPENDENCIES + rspec From 910010d246510f1dc4b657bf605ebd3684750837 Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 20 Feb 2014 09:34:43 -0800 Subject: [PATCH 06/23] Added partial yearly search. --- lib/api.rb | 22 +++++++++++++++++++++- lib/movie_list.rb | 13 +++++++++++++ movie_json.rb | 4 ++-- spec/api_spec.rb | 42 +++++++++++++++++++++++------------------- 4 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 lib/movie_list.rb diff --git a/lib/api.rb b/lib/api.rb index 8bf736d..fa856db 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -2,6 +2,7 @@ require "json" require "ostruct" require_relative "./movie" +require_relative "./movie_list" class Api APIKEY="4t6456xa33z8qhcqyuqgnkjh" @@ -9,13 +10,32 @@ class Api def self.search_by_title(title) url = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=#{APIKEY}&q=#{URI.encode(title)}&page_limit=1" struct = OpenStruct.new(get_url_as_json(url).fetch("movies").first) - Movie.build(id: struct.id.to_i, + search_by_year(struct.year) + Movie.new(id: struct.id.to_i, title: struct.title, year: struct.year, score: struct.ratings["critics_score"] ) end + def self.search_by_year(year) + url = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=#{APIKEY}&q=#{URI.encode(year.to_s)}&page_limit=49" + movies_in_year = get_url_as_json(url) + movies_in_year.fetch('movies').each do |movie| + # Movie.build(id: movie.fetch('id').to_i, + # title: movie.fetch('title'), + # year: movie.fetch('year'), + # score: movie.fetch('ratings').fetch('critics_score') + # ) + # end + if movie.fetch('year') == year + puts "ID: #{movie.fetch('id').to_i}" + puts "Title: #{movie.fetch('title')}" + puts "Year: #{movie.fetch('year')}" + puts "Rating: #{movie.fetch('ratings').fetch('critics_score')}" + end + end + end def self.get_url_as_json(url) JSON.parse(open(url).read) diff --git a/lib/movie_list.rb b/lib/movie_list.rb new file mode 100644 index 0000000..f98431c --- /dev/null +++ b/lib/movie_list.rb @@ -0,0 +1,13 @@ +require_relative "./movie" + +class MovieList + + def initialize + @@movie_list = [] + end + + def self.build(args) + movie = Movie.new(args) + @@movie_list << movie + end +end \ No newline at end of file diff --git a/movie_json.rb b/movie_json.rb index 5c93685..051efa3 100644 --- a/movie_json.rb +++ b/movie_json.rb @@ -13,14 +13,14 @@ def find_movie end find_movie -puts "The average rating is #{Movie.average_rating}." +puts "The average rating for all movies searched is #{Movie.average_rating}." while true do puts "Search Again (Y/N)" answer = gets.upcase[0] if answer == "Y" find_movie - puts "The average rating is #{Movie.average_rating}." + puts "The average rating for all movies searched is #{Movie.average_rating}." else break end diff --git a/spec/api_spec.rb b/spec/api_spec.rb index ac5da10..4af99c5 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -3,29 +3,33 @@ describe Api do - let(:movie) { Api.search_by_title("Forrest Gump") } + context "A movie" do + let(:movie) { Api.search_by_title("Forrest Gump") } - before do - Api.stub(:get_url_as_json) { JSON.parse(File.read("spec/fixtures/forrest.json")) } - end + before do + Api.stub(:get_url_as_json) { JSON.parse(File.read("spec/fixtures/forrest.json")) } + end - it "should search for movies" do - movie.title.should eq("Forrest Gump") - end + it "should search for movies" do + movie.title.should eq("Forrest Gump") + end - it "should return the score" do - movie.score.should eq(71) - end + it "should return the score" do + movie.score.should eq(71) + end - it "should return the id" do - movie.id.should eq(10036) - end + it "should return the id" do + movie.id.should eq(10036) + end - it "should return the year" do - movie.year.should eq(1994) - end + it "should return the year" do + movie.year.should eq(1994) + end - it "should not raise an error when searching for a non-existent movie" do - expect { Api.search_by_title("NOTHINGFOUNDHERE") }.to_not raise_error - end + it "should not raise an error when searching for a non-existent movie" do + expect { Api.search_by_title("NOTHINGFOUNDHERE") }.to_not raise_error + end + end + + context "" end From 3b547986c022af8df8eb56c2ecdf6da5c2dd707b Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 20 Feb 2014 21:11:03 +0200 Subject: [PATCH 07/23] Added MovieLibrary concept. --- lib/movie_library.rb | 15 +++++++++++++++ movie_json.rb | 3 ++- spec/fixtures/2010.json | 33 +++++++++++++++++++++++++++++++++ spec/movie_library_spec.rb | 26 ++++++++++++++++++++++++++ spec/movie_spec.rb | 4 ++-- 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 lib/movie_library.rb create mode 100644 spec/fixtures/2010.json create mode 100644 spec/movie_library_spec.rb diff --git a/lib/movie_library.rb b/lib/movie_library.rb new file mode 100644 index 0000000..cf5c032 --- /dev/null +++ b/lib/movie_library.rb @@ -0,0 +1,15 @@ +class MovieLibrary + + attr_reader :movies + def initialize + @movies = [] + end + + def self.all_movies + @movies + end + + def count + movies.count + end +end diff --git a/movie_json.rb b/movie_json.rb index 051efa3..4a62d55 100644 --- a/movie_json.rb +++ b/movie_json.rb @@ -7,6 +7,7 @@ def find_movie movie_title = gets movie = Api.search_by_title(movie_title) puts "Added: #{movie.title}. Score: #{movie.score}" + puts "Average score for the year: #{Movie.average_rating}" rescue NoMethodError puts "Not found." end @@ -20,7 +21,7 @@ def find_movie answer = gets.upcase[0] if answer == "Y" find_movie - puts "The average rating for all movies searched is #{Movie.average_rating}." + puts "Average score for the year: #{Movie.average_rating}" else break end diff --git a/spec/fixtures/2010.json b/spec/fixtures/2010.json new file mode 100644 index 0000000..85b30a0 --- /dev/null +++ b/spec/fixtures/2010.json @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{"total":44,"movies":[{"id":"770681152","title":"Shutter Island","year":2010,"mpaa_rating":"R","runtime":138,"critics_consensus":"It may not rank with Scorsese's best work, but Shutter Island's gleefully unapologetic genre thrills represent the director at his most unrestrained.","release_dates":{"theater":"2010-02-19","dvd":"2010-06-08"},"ratings":{"critics_rating":"Fresh","critics_score":69,"audience_rating":"Upright","audience_score":76},"synopsis":"Martin Scorsese and Leonardo DiCaprio team up for a fourth time for this adaptation of Shutter Island, a novel by Dennis Lehane (Mystic River). The film opens in 1954 as World War II veteran and current federal marshal Teddy Daniels (Leonardo DiCaprio) and his new partner, Chuck (Mark Ruffalo), ferry to Shutter Island, a water-bound mental hospital housing the criminally insane. They have been asked to investigate the disappearance of Rachel Solando (Emily Mortimer), a patient admitted to the asylum after she murdered her three children. As Teddy quizzes Dr. Cawley (Ben Kingsley), the head of the institution, he begins to suspect that the authorities in charge might not be giving him the whole truth, and that a terrible fate may befall all the patients in the spooky Ward C -- a unit devoted to the most heinous of the hospital's inmates. Complicating matters further, Teddy has a secret of his own -- the arsonist who murdered his wife is incarcerated on Shutter Island. Driven to confront his wife's killer, and stranded on the island because of a hurricane, Teddy must unravel the secrets of the eerie place before succumbing to his own madness. Max von Sydow, Emily Mortimer, Michelle Williams, Patricia Clarkson, and Jackie Earle Haley round out the supporting cast. ~ Perry Seibert, Rovi","posters":{"thumbnail":"http://content8.flixster.com/movie/11/16/92/11169254_mob.jpg","profile":"http://content8.flixster.com/movie/11/16/92/11169254_pro.jpg","detailed":"http://content8.flixster.com/movie/11/16/92/11169254_det.jpg","original":"http://content8.flixster.com/movie/11/16/92/11169254_ori.jpg"},"abridged_cast":[{"name":"Leonardo DiCaprio","id":"162659161","characters":["Teddy Daniels"]},{"name":"Mark Ruffalo","id":"162653904","characters":["Chuck Aule"]},{"name":"Ben Kingsley","id":"162653703","characters":["Dr. Cawley"]},{"name":"Michelle Williams","id":"162653583","characters":["Dolores"]},{"name":"Max von Sydow","id":"162657879","characters":["Dr. Naehring"]}],"alternate_ids":{"imdb":"1130884"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770681152.json","alternate":"http://www.rottentomatoes.com/m/1198124-shutter_island/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770681152/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/770681152/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770681152/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770681152/similar.json"}},{"id":"770683926","title":"Alice in Wonderland","year":2010,"mpaa_rating":"PG","runtime":109,"critics_consensus":"Tim Burton's Alice sacrifices the book's minimal narrative coherence -- and much of its heart -- but it's an undeniable visual treat.","release_dates":{"theater":"2010-03-05","dvd":"2010-06-01"},"ratings":{"critics_rating":"Rotten","critics_score":51,"audience_rating":"Spilled","audience_score":55},"synopsis":"n/a","posters":{"thumbnail":"http://content6.flixster.com/movie/10/93/73/10937308_mob.jpg","profile":"http://content6.flixster.com/movie/10/93/73/10937308_pro.jpg","detailed":"http://content6.flixster.com/movie/10/93/73/10937308_det.jpg","original":"http://content6.flixster.com/movie/10/93/73/10937308_ori.jpg"},"abridged_cast":[{"name":"Mia Wasikowska","id":"770688391","characters":["Alice"]},{"name":"Johnny Depp","id":"162652817","characters":["The Mad Hatter"]},{"name":"Anne Hathaway","id":"162656190","characters":["White Queen"]},{"name":"Helena Bonham Carter","id":"162652820","characters":["Red Queen"]},{"name":"Matt Lucas","id":"770698237","characters":["TweedleDee/TweedleDum"]}],"alternate_ids":{"imdb":"1014759"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770683926.json","alternate":"http://www.rottentomatoes.com/m/1221547-alice_in_wonderland/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770683926/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/770683926/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770683926/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770683926/similar.json"}},{"id":"770805766","title":"Valentine's Day","year":2010,"mpaa_rating":"PG-13","runtime":123,"critics_consensus":"Eager to please and stuffed with stars, Valentine's Day squanders its promise with a frantic, episodic plot and an abundance of rom-com cliches.","release_dates":{"theater":"2010-02-12","dvd":"2010-05-18"},"ratings":{"critics_rating":"Rotten","critics_score":18,"audience_rating":"Spilled","audience_score":48},"synopsis":"Gary Marshall's ensemble romantic comedy Valentine's Day follows nearly two dozen people as they find and lose love in all its many forms over the course of the title holiday. The numerous characters include a very busy florist (Ashton Kutcher) and his schoolteacher best friend (Jennifer Garner). She's having an affair with a married doctor (Patrick Dempsey). Meanwhile, a businessman (Bradley Cooper) and a military captain (Julia Roberts) on leave share a long conversation during an international flight. There's also an elderly couple (Hector Elizondo and Shirley MacLaine) who are caring for their elementary school-age grandson, who is pining for a classmate and missing his mother. The huge cast also includes Jamie Foxx as a local TV personality, Topher Grace, Queen Latifah, and Anne Hathaway. ~ Perry Seibert, Rovi","posters":{"thumbnail":"http://content6.flixster.com/movie/11/17/00/11170072_mob.jpg","profile":"http://content6.flixster.com/movie/11/17/00/11170072_pro.jpg","detailed":"http://content6.flixster.com/movie/11/17/00/11170072_det.jpg","original":"http://content6.flixster.com/movie/11/17/00/11170072_ori.jpg"},"abridged_cast":[{"name":"Julia Roberts","id":"162659460","characters":["Captain Kate Hazeltine"]},{"name":"Emma Roberts","id":"326298386","characters":["Grace"]},{"name":"Anne Hathaway","id":"162656190","characters":["Liz"]},{"name":"Jessica Alba","id":"162652782","characters":["Morley Clarkson"]},{"name":"Jessica Biel","id":"162652974","characters":["Kara Monahan"]}],"alternate_ids":{"imdb":"0817230"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770805766.json","alternate":"http://www.rottentomatoes.com/m/valentines_day_2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770805766/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/770805766/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770805766/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770805766/similar.json"}},{"id":"12419","title":"2010: The Year We Make Contact","year":1984,"mpaa_rating":"PG","runtime":114,"release_dates":{"theater":"1984-12-07","dvd":"1998-08-25"},"ratings":{"critics_rating":"Fresh","critics_score":66,"audience_rating":"Upright","audience_score":61},"synopsis":"","posters":{"thumbnail":"http://content7.flixster.com/movie/10/92/01/10920113_mob.jpg","profile":"http://content7.flixster.com/movie/10/92/01/10920113_pro.jpg","detailed":"http://content7.flixster.com/movie/10/92/01/10920113_det.jpg","original":"http://content7.flixster.com/movie/10/92/01/10920113_ori.jpg"},"abridged_cast":[{"name":"Roy Scheider","id":"162661798","characters":["Heywood Floyd"]},{"name":"John Lithgow","id":"162661569","characters":["Walter Curnow"]},{"name":"Helen Mirren","id":"162662871","characters":["Tanya Kirbuk"]},{"name":"Bob Balaban","id":"162674438","characters":["R. Chandra"]},{"name":"Keir Dullea","id":"162658493","characters":["Dave Bowman"]}],"alternate_ids":{"imdb":"0086837"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/12419.json","alternate":"http://www.rottentomatoes.com/m/2010_the_year_we_make_contact/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/12419/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/12419/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/12419/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/12419/similar.json"}},{"id":"771247738","title":"2010: Moby Dick","year":2010,"mpaa_rating":"Unrated","runtime":88,"release_dates":{"dvd":"2011-11-23"},"ratings":{"critics_score":-1,"audience_rating":"Spilled","audience_score":10},"synopsis":"Author Herman Melville's classic tale gets a modern-day makeover as the captain of a submarine hunts the massive whale that once disfigured him in a terrifying confrontation at sea. ~ Jason Buchanan, Rovi","posters":{"thumbnail":"http://content7.flixster.com/movie/11/15/86/11158689_mob.jpg","profile":"http://content7.flixster.com/movie/11/15/86/11158689_pro.jpg","detailed":"http://content7.flixster.com/movie/11/15/86/11158689_det.jpg","original":"http://content7.flixster.com/movie/11/15/86/11158689_ori.jpg"},"abridged_cast":[{"name":"Barry Bostwick","id":"162677211"},{"name":"Renee O'Connor","id":"519006652"},{"name":"Adam Grimes","id":"770744081"},{"name":"Michael Teh","id":"770688544"},{"name":"Matt Lagan","id":"770869281"}],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771247738.json","alternate":"http://www.rottentomatoes.com/m/2010_moby_dick/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771247738/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771247738/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771247738/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771247738/similar.json"}},{"id":"771035589","title":"2010 Writers Guild Awards","year":"","mpaa_rating":"Unrated","runtime":"","release_dates":{},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771035589.json","alternate":"http://www.rottentomatoes.com/m/2010_writers_guild_awards/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771035589/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771035589/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771035589/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771035589/similar.json"}},{"id":"771039092","title":"2010 NCAA Women's Final Four Championship","year":2010,"mpaa_rating":"Unrated","runtime":"","release_dates":{"dvd":"2010-05-18"},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"alternate_ids":{"imdb":"0316876"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039092.json","alternate":"http://www.rottentomatoes.com/m/2010_ncaa_womens_final_four_championship/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039092/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039092/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039092/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039092/similar.json"}},{"id":"771039093","title":"2010 NCAA Men's Final Four Championship: The Duke Blue Devils","year":2010,"mpaa_rating":"Unrated","runtime":"","release_dates":{"dvd":"2010-05-18"},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039093.json","alternate":"http://www.rottentomatoes.com/m/2010_ncaa_mens_final_four_championship_the_duke_blue_devils/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039093/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039093/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039093/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039093/similar.json"}},{"id":"771269394","title":"2010 Oscar Nominated Shorts Programme","year":2011,"mpaa_rating":"Unrated","runtime":98,"release_dates":{},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771269394.json","alternate":"http://www.rottentomatoes.com/m/2010_oscar_nominated_shorts_programme/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771269394/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771269394/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771269394/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771269394/similar.json"}},{"id":"514738215","title":"Knight Rider 2010","year":1994,"mpaa_rating":"Unrated","runtime":"","release_dates":{"theater":"1994-02-13"},"ratings":{"critics_score":-1,"audience_rating":"Spilled","audience_score":33},"synopsis":"","posters":{"thumbnail":"http://content6.flixster.com/movie/10/92/01/10920116_mob.jpg","profile":"http://content6.flixster.com/movie/10/92/01/10920116_pro.jpg","detailed":"http://content6.flixster.com/movie/10/92/01/10920116_det.jpg","original":"http://content6.flixster.com/movie/10/92/01/10920116_ori.jpg"},"abridged_cast":[{"name":"Michael Beach","id":"397673145"},{"name":"Ramon Chavez","id":"770946830","characters":["Professor"]},{"name":"Badja Djola","id":"351527524"},{"name":"Samuel Hernandez","id":"770933916","characters":["Bandit"]},{"name":"Brion James","id":"364636020","characters":["Jared"]}],"alternate_ids":{"imdb":"0110273"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/514738215.json","alternate":"http://www.rottentomatoes.com/m/knight-rider-2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/514738215/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/514738215/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/514738215/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/514738215/similar.json"}},{"id":"770855448","title":"Ice Castles (2010)","year":2010,"mpaa_rating":"PG","runtime":95,"release_dates":{"theater":"2010-02-09","dvd":"2010-02-09"},"ratings":{"critics_score":-1,"audience_rating":"Spilled","audience_score":48},"synopsis":"Oscar-nominated director Donald Wrye takes the helm for this remake of his own 1979 ice skating melodrama staring Robbie Benson. An overnight success in the hyper-competitive world of figure skating, Alexis Winston ditched her hometown boyfriend in a bid for superstardom. Alexis is at the top of her game when she's suddenly blinded in a tragic ice skating mishap. Her spirit broken, the fallen figure skater seeks the love that will help her lace up her skates, and reach for her dreams. ~ Jason Buchanan, Rovi","posters":{"thumbnail":"http://content8.flixster.com/movie/10/92/75/10927534_mob.jpg","profile":"http://content8.flixster.com/movie/10/92/75/10927534_pro.jpg","detailed":"http://content8.flixster.com/movie/10/92/75/10927534_det.jpg","original":"http://content8.flixster.com/movie/10/92/75/10927534_ori.jpg"},"abridged_cast":[{"name":"Taylor Firth","id":"770866450","characters":["Alexis Winston"]},{"name":"Rob Mayes","id":"770701513","characters":["Nick"]},{"name":"Henry Czerny","id":"343941171","characters":["Marcus"]},{"name":"Michelle Kwan","id":"770733281"},{"name":"Andrea Joyce","id":"770866451"}],"alternate_ids":{"imdb":"1412454"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770855448.json","alternate":"http://www.rottentomatoes.com/m/1221637-ice_castles/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770855448/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/770855448/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770855448/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770855448/similar.json"}},{"id":"770676741","title":"Tamala 2010: A Punk Cat in Space","year":2002,"mpaa_rating":"Unrated","runtime":92,"release_dates":{"theater":"2003-09-28"},"ratings":{"critics_rating":"Rotten","critics_score":46,"audience_rating":"Upright","audience_score":69},"synopsis":"","posters":{"thumbnail":"http://content6.flixster.com/movie/10/28/40/10284016_mob.jpg","profile":"http://content6.flixster.com/movie/10/28/40/10284016_pro.jpg","detailed":"http://content6.flixster.com/movie/10/28/40/10284016_det.jpg","original":"http://content6.flixster.com/movie/10/28/40/10284016_ori.jpg"},"abridged_cast":[{"name":"Shinji Takeda","id":"507075359"},{"name":"Beatrice Dalle","id":"359852908"},{"name":"Hisayo Mochizuki","id":"770683680"}],"alternate_ids":{"imdb":"0374262"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770676741.json","alternate":"http://www.rottentomatoes.com/m/tamala-2010-a-punk-cat-in-space/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770676741/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/770676741/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770676741/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770676741/similar.json"}},{"id":"770874917","title":"DCI 2010: The Countdown","year":2010,"mpaa_rating":"PG","runtime":120,"release_dates":{"theater":"2010-05-13"},"ratings":{"critics_score":-1,"audience_rating":"Upright","audience_score":67},"synopsis":"Kick off the 2010 season in a big way on the big screen! The best of the best in marching music are back for a one night event in select movie theaters nationwide. NCM Fathom and Drum Corps International are proud to present DCI 2010: The Countdown","posters":{"thumbnail":"http://content6.flixster.com/movie/10/95/55/10955536_mob.jpg","profile":"http://content6.flixster.com/movie/10/95/55/10955536_pro.jpg","detailed":"http://content6.flixster.com/movie/10/95/55/10955536_det.jpg","original":"http://content6.flixster.com/movie/10/95/55/10955536_ori.jpg"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770874917.json","alternate":"http://www.rottentomatoes.com/m/dci_2010_the_countdown/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770874917/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/770874917/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770874917/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770874917/similar.json"}},{"id":"771223458","title":"WWE: SummerSlam 2010","year":2010,"mpaa_rating":"Unrated","runtime":"","release_dates":{"dvd":"2011-10-18"},"ratings":{"critics_score":-1,"audience_rating":"Upright","audience_score":64},"synopsis":"Filmed in 2010 inside the Staples Center in Los Angeles, this all-star pay-per-view event features some of World Wrestling Entertainment's brightest superstars duking it out for big wins and bragging rights during the sweltering dog days of summer. Highlights include a multiwrestler brawl featuring the likes of John Cena, R-Truth, Chris Jericho, Edge, Wade Barrett, Heath Slater, Skip Sheffield and Michael Tarver.","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[{"name":"John Cena","id":"347990562"},{"name":"Big Show","id":"770737516"},{"name":"Undertaker","id":"770737957"},{"name":"Chris Jericho","id":"770681104"},{"name":"Edge","id":"770689655"}],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771223458.json","alternate":"http://www.rottentomatoes.com/m/wwe_summerslam_2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771223458/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771223458/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771223458/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771223458/similar.json"}},{"id":"771204041","title":"Eric Clapton: Crossroads Guitar Festival 2010","year":2010,"mpaa_rating":"Unrated","runtime":"","release_dates":{"dvd":"2010-11-09"},"ratings":{"critics_score":-1,"audience_rating":"Upright","audience_score":100},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[{"name":"B.B. King","id":"162661560"},{"name":"Bill Murray","id":"162653064"},{"name":"Buddy Guy","id":"162660534"},{"name":"Eric Clapton","id":"335719505"},{"name":"Jeff Beck","id":"770720906"}],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771204041.json","alternate":"http://www.rottentomatoes.com/m/eric_clapton_crossroads_guitar_festival_2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771204041/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771204041/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771204041/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771204041/similar.json"}},{"id":"770813559","title":"Fahrenheit 2010: Warming Up for the World Cup in South Africa","year":2009,"mpaa_rating":"Unrated","runtime":52,"release_dates":{},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770813559.json","alternate":"http://www.rottentomatoes.com/m/fahrenheit-2010-warming-up-for-the-world-cup-in-south-africa/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770813559/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/770813559/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770813559/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770813559/similar.json"}},{"id":"771039639","title":"All's Well, Ends Well 2010","year":2010,"mpaa_rating":"Unrated","runtime":93,"release_dates":{"dvd":"2010-05-25"},"ratings":{"critics_score":-1,"audience_rating":"Spilled","audience_score":22},"synopsis":"After spending a decade honing her ceremonial skills in the Midland, Princess Pearl of Flowerland returns home under orders from her father. On her way back, Princess Pearl finds herself smitten with General Wing, a strong leader in the Midland Army. Shortly after General Wing rescues a young woman named Ying from taking her own life, the travelers are besieged by a gang of pirates and Princess Pearl falls overboard during the attack. Miraculously, Princess Pearl is saved by Ying's father. Now the princess suffers from amnesia. But General Wing knows that Princess Pearl is still alive, and he won't rests until his true love is back in his arms. ~ Jason Buchanan, Rovi","posters":{"thumbnail":"http://content9.flixster.com/movie/11/15/17/11151703_mob.jpg","profile":"http://content9.flixster.com/movie/11/15/17/11151703_pro.jpg","detailed":"http://content9.flixster.com/movie/11/15/17/11151703_det.jpg","original":"http://content9.flixster.com/movie/11/15/17/11151703_ori.jpg"},"abridged_cast":[{"name":"Sandra Ng Kwan Yue","id":"603266699"},{"name":"Louis Koo","id":"162675099"},{"name":"Ronald Cheng","id":"496181128"},{"name":"Raymond Wong","id":"770692982"},{"name":"Lin Hung","id":"771074541"}],"alternate_ids":{"imdb":"0077148"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039639.json","alternate":"http://www.rottentomatoes.com/m/alls_well_ends_well_2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039639/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039639/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039639/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771039639/similar.json"}},{"id":"771029221","title":"Sci-Fi Film Classics 2010 Calendar","year":2010,"mpaa_rating":"Unrated","runtime":"","release_dates":{"dvd":"2010-03-23"},"ratings":{"critics_score":-1,"audience_rating":"Upright","audience_score":100},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771029221.json","alternate":"http://www.rottentomatoes.com/m/sci_fi_film_classics_2010_calendar/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771029221/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771029221/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771029221/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771029221/similar.json"}},{"id":"771202431","title":"Eric Clapton Crossroads 2010","year":2010,"mpaa_rating":"G","runtime":240,"release_dates":{"theater":"2010-07-27"},"ratings":{"critics_score":-1,"audience_rating":"Upright","audience_score":100},"synopsis":"Eric Clapton's Crossroads Guitar Festival 2010 was a day-long musical celebration featuring legendary guitarists and artistic collaborations by Eric and his friends including Allman Brothers Band, BB King, Buddy Guy, Jeff Beck, John Mayer, Sheryl Crow, Steve Winwood, Vince Gill, ZZ Top, and more. Crossroads Guitar Festival 2010 took place on Saturday, June 26 at Toyota Park in Chicago. The following artists participated in this unique event to benefit Crossroads Centre Antigua: Albert Lee, BB King, Bert Jansch, Buddy Guy, David Hidalgo and Cesar Rosas of Los Lobos, Derek Trucks, Doyle Bramhall II, Earl Klugh, Eric Clapton, Gary Clark Jr., Hubert Sumlin, James Burton, Jeff Beck, Jimmie Vaughan, Joe Bonamassa, John Mayer, Johnny Winter, Jonny Lang, Keb' Mo', Pino Daniele, Robert Cray, Robert Randolph, Sheryl Crow, Susan Tedeschi, Sonny Landreth, Stefan Grossman, Steve Winwood, Vince Gill, Warren Haynes, and ZZ Top. --© Official Site","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[{"name":"Stefan Grossman","id":"770713120"},{"name":"Buddy Guy","id":"162660534"},{"name":"B.B. King","id":"162661560"},{"name":"Jimmie Vaughan","id":"770721638"},{"name":"Ronnie Wood","id":"770715577"}],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202431.json","alternate":"http://www.rottentomatoes.com/m/eric_clapton_crossroads_2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202431/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202431/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202431/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202431/similar.json"}},{"id":"771268086","title":"NHL Stanley Cup Champions 2010: Chicago Blackhawks","year":2010,"mpaa_rating":"Unrated","runtime":200,"release_dates":{},"ratings":{"critics_score":-1,"audience_score":100},"synopsis":"For the first time in 49 years, the Chicago Blackhawks are Stanley Cup Champions. Young superstars Jonathan Toews and Patrick Kane, franchise defenseman Duncan Keith, breakout power forward Dustin Byfuglien and classy winger Marian Hossa flash their talents in front of emerging goaltender Antti Niemi to bring hockey's most coveted trophy back to the Windy City. Now, you can relive every step of their championship season from the NHL Premiere in Helsinki to the dramatic Stanley Cup Final against the Philadelphia Flyers. Follow the Hawks as they capture their first Central Division title and face-off with Nashville, Vancouver, San Jose and the Flyers during the Stanley Cup Playoffs. Go inside the glass and into the locker room with exclusive footage and interviews with players, coaches and franchise legends. Recapture all the unforgettable glory of the 2010 Stanley Cup Champion Chicago Blackhawks!","posters":{"thumbnail":"http://content8.flixster.com/movie/11/16/33/11163334_mob.jpg","profile":"http://content8.flixster.com/movie/11/16/33/11163334_pro.jpg","detailed":"http://content8.flixster.com/movie/11/16/33/11163334_det.jpg","original":"http://content8.flixster.com/movie/11/16/33/11163334_ori.jpg"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771268086.json","alternate":"http://www.rottentomatoes.com/m/nhl_stanley_cup_champions_2010_chicago_blackhawks/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771268086/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771268086/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771268086/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771268086/similar.json"}},{"id":"770859486","title":"Zeche Is Nich - Sieben Blicke Auf Das Ruhrgebiet 2010","year":2010,"mpaa_rating":"Unrated","runtime":"","release_dates":{"theater":"2010-12-31"},"ratings":{"critics_score":-1,"audience_rating":"Upright","audience_score":100},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[{"name":"Roozbeh Farhangmehr","id":"770874011"},{"name":"Sinan Farhangmehr","id":"770874012"},{"name":"Manfred Mock","id":"770704536"}],"alternate_ids":{"imdb":"1511525"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770859486.json","alternate":"http://www.rottentomatoes.com/m/zeche_is_nich_sieben_blicke_auf_das_ruhrgebiet_2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770859486/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/770859486/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770859486/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770859486/similar.json"}},{"id":"771035588","title":"Orange British Academy Film Awards 2010","year":"","mpaa_rating":"Unrated","runtime":"","release_dates":{},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771035588.json","alternate":"http://www.rottentomatoes.com/m/orange_british_academy_film_awards_2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771035588/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771035588/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771035588/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771035588/similar.json"}},{"id":"771029228","title":"Musicals Film Classics 2010 Calendar","year":2010,"mpaa_rating":"Unrated","runtime":"","release_dates":{"dvd":"2010-03-23"},"ratings":{"critics_score":-1,"audience_rating":"Upright","audience_score":100},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771029228.json","alternate":"http://www.rottentomatoes.com/m/musicals_film_classics_2010_calendar/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771029228/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771029228/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771029228/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771029228/similar.json"}},{"id":"771202601","title":"TNA Wrestling: Slammiversary 2010","year":2010,"mpaa_rating":"Unrated","runtime":"","release_dates":{"dvd":"2010-08-24"},"ratings":{"critics_score":-1,"audience_rating":"Upright","audience_score":100},"synopsis":"","posters":{"thumbnail":"http://content7.flixster.com/movie/11/15/20/11152069_mob.jpg","profile":"http://content7.flixster.com/movie/11/15/20/11152069_pro.jpg","detailed":"http://content7.flixster.com/movie/11/15/20/11152069_det.jpg","original":"http://content7.flixster.com/movie/11/15/20/11152069_ori.jpg"},"abridged_cast":[],"alternate_ids":{"imdb":"0467006"},"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202601.json","alternate":"http://www.rottentomatoes.com/m/tna_wrestling_slammiversary_2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202601/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202601/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202601/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202601/similar.json"}},{"id":"771202663","title":"Teensplash 2010, Part 1","year":"","mpaa_rating":"Unrated","runtime":"","release_dates":{},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://content8.flixster.com/movie/11/14/30/11143098_mob.jpg","profile":"http://content8.flixster.com/movie/11/14/30/11143098_pro.jpg","detailed":"http://content8.flixster.com/movie/11/14/30/11143098_det.jpg","original":"http://content8.flixster.com/movie/11/14/30/11143098_ori.jpg"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202663.json","alternate":"http://www.rottentomatoes.com/m/teensplash_2010_part_1/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202663/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202663/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202663/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771202663/similar.json"}},{"id":"771203395","title":"Dci 2010: Big, Loud & Live 7","year":2010,"mpaa_rating":"G","runtime":"","release_dates":{"theater":"2010-08-12","dvd":"2010-09-01"},"ratings":{"critics_score":-1,"audience_rating":"Upright","audience_score":100},"synopsis":"August 12, 2010 - one night event. Drum Corps International World Championships, Big Loud & Live from the world championship quarterfinals.","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771203395.json","alternate":"http://www.rottentomatoes.com/m/dci_2010_big_loud_and_live_7/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771203395/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771203395/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771203395/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771203395/similar.json"}},{"id":"770863928","title":"Oscar Nominated Shorts 2010","year":2010,"mpaa_rating":"Unrated","runtime":190,"release_dates":{},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"Shorts International will once again bring the Oscar (R) nominated short film program (live-action and animation) to theaters in the United States, Canada, Mexico and the United Kingdom beginning Feb. 19. The theatrical release of the Academy Award (R) nominated short films, which has met with enthusiastic audiences ever since its launch five years ago, will give people around the world an opportunity to see the nominated films prior to the 82 Academy Awards (R) ceremony on March 7.","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770863928.json","alternate":"http://www.rottentomatoes.com/m/oscar-nominated-shorts-2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770863928/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/770863928/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770863928/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770863928/similar.json"}},{"id":"770874314","title":"Spike And Mike Sick And Twisted Festival Of Animation 2010","year":2010,"mpaa_rating":"Unrated","runtime":"","release_dates":{},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/770874314.json","alternate":"http://www.rottentomatoes.com/m/spike_and_mike_sick_and_twisted_festival_of_animation_2010/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/770874314/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/770874314/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/770874314/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/770874314/similar.json"}},{"id":"771040671","title":"Cannes 2010 Programme Courts 1","year":2013,"mpaa_rating":"Unrated","runtime":91,"release_dates":{},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771040671.json","alternate":"http://www.rottentomatoes.com/m/cannes_2010_programme_courts_1/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771040671/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771040671/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771040671/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771040671/similar.json"}},{"id":"771041072","title":"Cannes 2010 Programme Courts 2","year":2013,"mpaa_rating":"Unrated","runtime":84,"release_dates":{},"ratings":{"critics_score":-1,"audience_score":0},"synopsis":"","posters":{"thumbnail":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","profile":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","detailed":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif","original":"http://images.rottentomatoescdn.com/images/redesign/poster_default.gif"},"abridged_cast":[],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies/771041072.json","alternate":"http://www.rottentomatoes.com/m/cannes_2010_programme_courts_2/","cast":"http://api.rottentomatoes.com/api/public/v1.0/movies/771041072/cast.json","clips":"http://api.rottentomatoes.com/api/public/v1.0/movies/771041072/clips.json","reviews":"http://api.rottentomatoes.com/api/public/v1.0/movies/771041072/reviews.json","similar":"http://api.rottentomatoes.com/api/public/v1.0/movies/771041072/similar.json"}}],"links":{"self":"http://api.rottentomatoes.com/api/public/v1.0/movies.json?q=2010&page_limit=30&page=1","next":"http://api.rottentomatoes.com/api/public/v1.0/movies.json?q=2010&page_limit=30&page=2"},"link_template":"http://api.rottentomatoes.com/api/public/v1.0/movies.json?q={search-term}&page_limit={results-per-page}&page={page-number}"} diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb new file mode 100644 index 0000000..e94aaea --- /dev/null +++ b/spec/movie_library_spec.rb @@ -0,0 +1,26 @@ +require 'rspec' +require_relative "../lib/movie_library" +describe MovieLibrary do + + let(:movie_library) {MovieLibrary.new} + describe "#new" do + + it 'should be a movie library object ' do + movie_library.is_a?(MovieLibrary).should be_true + end + + it 'should have no movies when initialized' do + movie_library.count.should eq(0) + end + end + + describe "#register" do + it 'should add a new movie to the library whenever a search happens' do + movie = mock(:movie) + expect(MovieLibrary.all_movies).to include (movie) + end + xit 'should increase the movie count' do + + end + end +end diff --git a/spec/movie_spec.rb b/spec/movie_spec.rb index 14c5102..b36c4c5 100644 --- a/spec/movie_spec.rb +++ b/spec/movie_spec.rb @@ -13,7 +13,7 @@ movie.score.should eq(50) end - it 'should inherit from vehicle' do + it 'should a movie object' do movie.is_a?(Movie).should be_true end @@ -23,7 +23,7 @@ end describe ".build" do - + it "records the movie when I build it" do movie = Movie.build(id: 10020, title: 'Pirates of the Caribbean: The Curse of the Black Pearl', year: 2003, score: 79) expect(Movie.all_movies).to include (movie) From 32fddc6ece63eef8d7e2dc7ce55b9cfb868476c1 Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 20 Feb 2014 21:12:37 +0200 Subject: [PATCH 08/23] Deleted MovieList class. --- lib/movie_list.rb | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 lib/movie_list.rb diff --git a/lib/movie_list.rb b/lib/movie_list.rb deleted file mode 100644 index f98431c..0000000 --- a/lib/movie_list.rb +++ /dev/null @@ -1,13 +0,0 @@ -require_relative "./movie" - -class MovieList - - def initialize - @@movie_list = [] - end - - def self.build(args) - movie = Movie.new(args) - @@movie_list << movie - end -end \ No newline at end of file From b7701473cbc7ed9bab6556e5a14e7f9f7e52ece4 Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 20 Feb 2014 22:41:16 +0200 Subject: [PATCH 09/23] Added MovieLibrary#average_rating. --- lib/movie.rb | 2 ++ lib/movie_library.rb | 10 +++++++++- spec/movie_library_spec.rb | 20 +++++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/movie.rb b/lib/movie.rb index 9d27ffc..47521db 100644 --- a/lib/movie.rb +++ b/lib/movie.rb @@ -1,3 +1,4 @@ +require_relative './movie_library' class Movie @@movies = [] @@ -7,6 +8,7 @@ def initialize(hash={}) @title = hash.fetch(:title) @year = hash.fetch(:year) @score = hash.fetch(:score) + MovieLibrary.new.register(self) end def self.build(args) diff --git a/lib/movie_library.rb b/lib/movie_library.rb index cf5c032..cf8d5e6 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -5,7 +5,15 @@ def initialize @movies = [] end - def self.all_movies + def average_rating + all_movies.inject(0.0) { |sum, movie| sum + movie.score } / all_movies.size + end + + def register(movie) + @movies << movie + end + + def all_movies @movies end diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb index e94aaea..d446704 100644 --- a/spec/movie_library_spec.rb +++ b/spec/movie_library_spec.rb @@ -1,8 +1,10 @@ require 'rspec' +require_relative "../lib/movie" require_relative "../lib/movie_library" describe MovieLibrary do let(:movie_library) {MovieLibrary.new} + let (:movie){Movie.new(id: "the-id", title: "the-title", year: 1998, score: 50)} describe "#new" do it 'should be a movie library object ' do @@ -15,11 +17,23 @@ end describe "#register" do + it 'should add a new movie to the library whenever a search happens' do - movie = mock(:movie) - expect(MovieLibrary.all_movies).to include (movie) + movie_library.register(movie) + expect(movie_library.all_movies).to include (movie) + end + it 'should increase the movie count' do + movie_library.register(movie) + movie_library.count.should eq(1) + end + end + + describe "#average_rating" do + it "should have no average rating initially" do + movie_library.average_rating.should eq(0) end - xit 'should increase the movie count' do + + xit 'should calculate the average rating' do end end From 527e8342e119d7c560f46d29232fa7e6a9d97176 Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 20 Feb 2014 22:58:12 +0200 Subject: [PATCH 10/23] Code clean-up. --- lib/api.rb | 20 -------------------- lib/movie.rb | 20 -------------------- spec/movie_library_spec.rb | 7 ++++--- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/lib/api.rb b/lib/api.rb index fa856db..12b6720 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -10,7 +10,6 @@ class Api def self.search_by_title(title) url = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=#{APIKEY}&q=#{URI.encode(title)}&page_limit=1" struct = OpenStruct.new(get_url_as_json(url).fetch("movies").first) - search_by_year(struct.year) Movie.new(id: struct.id.to_i, title: struct.title, year: struct.year, @@ -18,25 +17,6 @@ def self.search_by_title(title) ) end - def self.search_by_year(year) - url = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=#{APIKEY}&q=#{URI.encode(year.to_s)}&page_limit=49" - movies_in_year = get_url_as_json(url) - movies_in_year.fetch('movies').each do |movie| - # Movie.build(id: movie.fetch('id').to_i, - # title: movie.fetch('title'), - # year: movie.fetch('year'), - # score: movie.fetch('ratings').fetch('critics_score') - # ) - # end - if movie.fetch('year') == year - puts "ID: #{movie.fetch('id').to_i}" - puts "Title: #{movie.fetch('title')}" - puts "Year: #{movie.fetch('year')}" - puts "Rating: #{movie.fetch('ratings').fetch('critics_score')}" - end - end - end - def self.get_url_as_json(url) JSON.parse(open(url).read) end diff --git a/lib/movie.rb b/lib/movie.rb index 47521db..f1e1f7a 100644 --- a/lib/movie.rb +++ b/lib/movie.rb @@ -1,32 +1,12 @@ require_relative './movie_library' class Movie - @@movies = [] attr_reader :id, :title, :year, :score def initialize(hash={}) @id = hash.fetch(:id) @title = hash.fetch(:title) @year = hash.fetch(:year) @score = hash.fetch(:score) - MovieLibrary.new.register(self) - end - - def self.build(args) - movie = Movie.new(args) - @@movies << movie - movie - end - - def self.average_rating - all_movies.inject(0.0) { |sum, movie| sum + movie.score } / all_movies.size - end - - def self.count - @@movies.count - end - - def self.all_movies - @@movies end end diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb index d446704..77870a1 100644 --- a/spec/movie_library_spec.rb +++ b/spec/movie_library_spec.rb @@ -29,12 +29,13 @@ end describe "#average_rating" do - it "should have no average rating initially" do + it "should have no average rating when no movies are cataloged" do movie_library.average_rating.should eq(0) end - xit 'should calculate the average rating' do - + it 'should calculate the average rating' do + movie_library.register(movie) + movie_library.average_rating.should eq(50) end end end From 048dce504b8e1c52717950cb2a93fe8036035f52 Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 20 Feb 2014 23:19:59 +0200 Subject: [PATCH 11/23] In Ruby, dividing by zero doesn't always raise a ZeroDivisionError - NaN. --- lib/movie_library.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/movie_library.rb b/lib/movie_library.rb index cf8d5e6..7f79684 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -6,6 +6,7 @@ def initialize end def average_rating + return 0 if count == 0 all_movies.inject(0.0) { |sum, movie| sum + movie.score } / all_movies.size end From d3a2f342dc4fd1e1bbb197f4e4ee6bc393af61ea Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 20 Feb 2014 23:26:13 +0200 Subject: [PATCH 12/23] Removed unnecessary test from movie_spec.rb --- spec/movie_spec.rb | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/spec/movie_spec.rb b/spec/movie_spec.rb index b36c4c5..00de55f 100644 --- a/spec/movie_spec.rb +++ b/spec/movie_spec.rb @@ -16,35 +16,6 @@ it 'should a movie object' do movie.is_a?(Movie).should be_true end - - it 'should not change the movie count' do - Movie.count.should eq(0) - end end - describe ".build" do - - it "records the movie when I build it" do - movie = Movie.build(id: 10020, title: 'Pirates of the Caribbean: The Curse of the Black Pearl', year: 2003, score: 79) - expect(Movie.all_movies).to include (movie) - end - - it "should increment the movie count" do - expect{Movie.build(id: 10036, title: 'Forrest Gump', year: 1994, score: 71)}.to change{Movie.count}.from(1).to(2) - end - end - - describe ".average_rating" do - it "should have no average rating initially" do - #how do you mock this scenario - end - - it 'should calculate the average rating while ignoring the Movie#build calls above' do - #how do you change scope for RSpec object. Or rather how do you reset the Movie object instance variables? - end - - it "should calculate the average rating for Forrest Gump and Pirates of the...as 75 " do - Movie.average_rating.should eq(75) - end - end end From 86c4e24952a432386aafb1fc0f4981b0efa1cd78 Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 20 Feb 2014 23:54:37 +0200 Subject: [PATCH 13/23] General clean-up and regression testing. --- lib/api.rb | 2 +- lib/movie_library.rb | 2 +- movie_json.rb | 16 ++++++++++------ spec/api_spec.rb | 3 --- spec/movie_library_spec.rb | 8 ++++---- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/api.rb b/lib/api.rb index 12b6720..ffd04d5 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -2,7 +2,7 @@ require "json" require "ostruct" require_relative "./movie" -require_relative "./movie_list" +require_relative "./movie_library" class Api APIKEY="4t6456xa33z8qhcqyuqgnkjh" diff --git a/lib/movie_library.rb b/lib/movie_library.rb index 7f79684..697b5c9 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -10,7 +10,7 @@ def average_rating all_movies.inject(0.0) { |sum, movie| sum + movie.score } / all_movies.size end - def register(movie) + def catalog(movie) @movies << movie end diff --git a/movie_json.rb b/movie_json.rb index 4a62d55..0014abc 100644 --- a/movie_json.rb +++ b/movie_json.rb @@ -1,4 +1,5 @@ require_relative "lib/movie" +require_relative "lib/movie_library" require_relative "lib/api" def find_movie @@ -6,22 +7,25 @@ def find_movie puts "OH HAI. Add a movie you really like?" movie_title = gets movie = Api.search_by_title(movie_title) - puts "Added: #{movie.title}. Score: #{movie.score}" - puts "Average score for the year: #{Movie.average_rating}" rescue NoMethodError puts "Not found." end end -find_movie -puts "The average rating for all movies searched is #{Movie.average_rating}." +movie_library = MovieLibrary.new +movie = find_movie +movie_library.catalog(movie) +puts "Found: #{movie.title}. Score: #{movie.score}" +puts "The average rating for all movies searched thus far is #{movie_library.average_rating}." while true do puts "Search Again (Y/N)" answer = gets.upcase[0] if answer == "Y" - find_movie - puts "Average score for the year: #{Movie.average_rating}" + movie = find_movie + movie_library.catalog(movie) + puts "Found: #{movie.title}. Score: #{movie.score}" + puts "The average rating for all movies searched thus far is #{movie_library.average_rating}." else break end diff --git a/spec/api_spec.rb b/spec/api_spec.rb index 4af99c5..eb2db46 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -3,7 +3,6 @@ describe Api do - context "A movie" do let(:movie) { Api.search_by_title("Forrest Gump") } before do @@ -29,7 +28,5 @@ it "should not raise an error when searching for a non-existent movie" do expect { Api.search_by_title("NOTHINGFOUNDHERE") }.to_not raise_error end - end - context "" end diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb index 77870a1..180aa7a 100644 --- a/spec/movie_library_spec.rb +++ b/spec/movie_library_spec.rb @@ -16,14 +16,14 @@ end end - describe "#register" do + describe "#catalog" do it 'should add a new movie to the library whenever a search happens' do - movie_library.register(movie) + movie_library.catalog(movie) expect(movie_library.all_movies).to include (movie) end it 'should increase the movie count' do - movie_library.register(movie) + movie_library.catalog(movie) movie_library.count.should eq(1) end end @@ -34,7 +34,7 @@ end it 'should calculate the average rating' do - movie_library.register(movie) + movie_library.catalog(movie) movie_library.average_rating.should eq(50) end end From b977711b3752fea7a60f2e0b304736d79774ef1f Mon Sep 17 00:00:00 2001 From: drammopo Date: Fri, 21 Feb 2014 00:14:54 +0200 Subject: [PATCH 14/23] Added yearly average method. --- lib/movie.rb | 1 - lib/movie_library.rb | 6 ++++++ spec/movie_library_spec.rb | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/movie.rb b/lib/movie.rb index f1e1f7a..20d7f56 100644 --- a/lib/movie.rb +++ b/lib/movie.rb @@ -8,5 +8,4 @@ def initialize(hash={}) @year = hash.fetch(:year) @score = hash.fetch(:score) end - end diff --git a/lib/movie_library.rb b/lib/movie_library.rb index 697b5c9..0c9051b 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -5,6 +5,12 @@ def initialize @movies = [] end + def average_rating_by_year(year) + result = all_movies.select {|movie| movie.year == year} + return 0 if result.length == 0 + result.inject(0.0) { |sum, movie| sum + movie.score } / result.size + end + def average_rating return 0 if count == 0 all_movies.inject(0.0) { |sum, movie| sum + movie.score } / all_movies.size diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb index 180aa7a..614758a 100644 --- a/spec/movie_library_spec.rb +++ b/spec/movie_library_spec.rb @@ -29,6 +29,7 @@ end describe "#average_rating" do + it "should have no average rating when no movies are cataloged" do movie_library.average_rating.should eq(0) end @@ -38,4 +39,18 @@ movie_library.average_rating.should eq(50) end end + + describe "#average_rating_by_year" do + + it 'should have no average yearly rating when no movies are cataloged' do + movie_library.average_rating_by_year(movie.year).should eq(0) + end + + it 'should calculate the average rating by year when the library has' do + movie_library.catalog(Movie.new(id: "the-id", title: "the-title", year: 1998, score: 50)) + movie_library.catalog(Movie.new(id: "the-id", title: "the-title", year: 2000, score: 50)) + movie_library.catalog(Movie.new(id: "the-id", title: "the-title", year: 1998, score: 50)) + movie_library.average_rating_by_year(1998).should eq(50) + end + end end From 12f27b0e94cbf88e4b6d1c98882d10e1a4cc1f0b Mon Sep 17 00:00:00 2001 From: drammopo Date: Fri, 21 Feb 2014 00:37:29 +0200 Subject: [PATCH 15/23] Refactored MovieLibrary#average_rating. --- lib/movie_library.rb | 6 +++--- spec/movie_library_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/movie_library.rb b/lib/movie_library.rb index 0c9051b..76d484a 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -8,12 +8,12 @@ def initialize def average_rating_by_year(year) result = all_movies.select {|movie| movie.year == year} return 0 if result.length == 0 - result.inject(0.0) { |sum, movie| sum + movie.score } / result.size + average_rating(result) end - def average_rating + def average_rating(movies) return 0 if count == 0 - all_movies.inject(0.0) { |sum, movie| sum + movie.score } / all_movies.size + movies.inject(0.0) { |sum, movie| sum + movie.score } / movies.size end def catalog(movie) diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb index 614758a..3b2a1e8 100644 --- a/spec/movie_library_spec.rb +++ b/spec/movie_library_spec.rb @@ -31,12 +31,12 @@ describe "#average_rating" do it "should have no average rating when no movies are cataloged" do - movie_library.average_rating.should eq(0) + movie_library.average_rating(Array.new).should eq(0) end it 'should calculate the average rating' do movie_library.catalog(movie) - movie_library.average_rating.should eq(50) + movie_library.average_rating(movie_library.all_movies).should eq(50) end end From 7f81c5996dbe93fbed33c5dd6f0d61ab29dfb796 Mon Sep 17 00:00:00 2001 From: drammopo Date: Fri, 21 Feb 2014 07:58:01 +0200 Subject: [PATCH 16/23] Further refactoring of MovieLibrary#average_rating. --- lib/movie.rb | 1 - lib/movie_library.rb | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/movie.rb b/lib/movie.rb index 20d7f56..167a23e 100644 --- a/lib/movie.rb +++ b/lib/movie.rb @@ -1,4 +1,3 @@ -require_relative './movie_library' class Movie attr_reader :id, :title, :year, :score diff --git a/lib/movie_library.rb b/lib/movie_library.rb index 76d484a..e8094c9 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -6,9 +6,7 @@ def initialize end def average_rating_by_year(year) - result = all_movies.select {|movie| movie.year == year} - return 0 if result.length == 0 - average_rating(result) + average_rating all_movies.select {|movie| movie.year == year} end def average_rating(movies) From 5b786f0fb6b786723ed89efeeafd06eaa1e5ad62 Mon Sep 17 00:00:00 2001 From: drammopo Date: Fri, 21 Feb 2014 23:28:48 +0200 Subject: [PATCH 17/23] Add slope calculation. --- README.md | 2 +- lib/movie_library.rb | 9 +++++++++ spec/movie_library_spec.rb | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7400674..b935f33 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Slope of line is `(y1 - y2) / (x1 - x2)` ... In this case, if my average rating ``` (45 - 50).to_f / (2012 - 1990).to_f -=> -0.22727272727272727 +=> -0.22727272727272727 # getting madder ``` diff --git a/lib/movie_library.rb b/lib/movie_library.rb index e8094c9..2ae30cd 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -5,6 +5,15 @@ def initialize @movies = [] end + def calculate_slope + sorted_catalog = sort_by_year + (sorted_catalog.first.score - sorted_catalog.last.score).to_f / (sorted_catalog.last.year - sorted_catalog.first.year).to_f + end + + def sort_by_year + all_movies.sort { |movie,another_movie| movie.year <=> another_movie.year } + end + def average_rating_by_year(year) average_rating all_movies.select {|movie| movie.year == year} end diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb index 3b2a1e8..f2ed71c 100644 --- a/spec/movie_library_spec.rb +++ b/spec/movie_library_spec.rb @@ -53,4 +53,25 @@ movie_library.average_rating_by_year(1998).should eq(50) end end + + describe "#sort_by_year" do + + it 'should sort the movies by year' do + another_movie = Movie.new(id: "the-id", title: "the-title", year: 2012, score: 50) + yet_another_movie = Movie.new(id: "the-id", title: "the-title", year: 1990, score: 45) + movie_library.catalog(another_movie) + movie_library.catalog(yet_another_movie) + movie_library.sort_by_year.should == [yet_another_movie, another_movie] + end + end + + describe "#calculate_slope" do + it 'should calculate the slope of the average ratings from the first year to the last year' do + another_movie = Movie.new(id: "the-id", title: "the-title", year: 2012, score: 50) + yet_another_movie = Movie.new(id: "the-id", title: "the-title", year: 1990, score: 45) + movie_library.catalog(another_movie) + movie_library.catalog(yet_another_movie) + movie_library.calculate_slope.should eq(-0.22727272727272727) + end + end end From 78d49fd7c48a58ba5540afb2b492b8fa7f704645 Mon Sep 17 00:00:00 2001 From: drammopo Date: Sat, 22 Feb 2014 17:10:43 +0200 Subject: [PATCH 18/23] Fixed #calculate_slope. Using #catalog to handle all dependencies. --- lib/movie_library.rb | 18 ++++++++++++------ spec/movie_library_spec.rb | 16 +++++++--------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/movie_library.rb b/lib/movie_library.rb index 2ae30cd..971bd10 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -1,17 +1,20 @@ class MovieLibrary - attr_reader :movies + attr_reader :movies, :library, :slope def initialize @movies = [] + @library = [] + @slope = 0 end - def calculate_slope - sorted_catalog = sort_by_year - (sorted_catalog.first.score - sorted_catalog.last.score).to_f / (sorted_catalog.last.year - sorted_catalog.first.year).to_f + def calculate_slope(catalog) + first = catalog.first + last = catalog.last + (first.score - last.score).to_f / (last.year - first.year).to_f end - def sort_by_year - all_movies.sort { |movie,another_movie| movie.year <=> another_movie.year } + def sort_by_year(movies) + movies.sort { |movie,another_movie| movie.year <=> another_movie.year } end def average_rating_by_year(year) @@ -25,6 +28,9 @@ def average_rating(movies) def catalog(movie) @movies << movie + @library = sort_by_year(@movies) + @slope = calculate_slope(@library) + return @library end def all_movies diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb index f2ed71c..19ab6eb 100644 --- a/spec/movie_library_spec.rb +++ b/spec/movie_library_spec.rb @@ -5,6 +5,8 @@ let(:movie_library) {MovieLibrary.new} let (:movie){Movie.new(id: "the-id", title: "the-title", year: 1998, score: 50)} + let (:another_movie){Movie.new(id: "the-id", title: "the-title", year: 2012, score: 50)} + let (:yet_another_movie){Movie.new(id: "the-id", title: "the-title", year: 1990, score: 45)} describe "#new" do it 'should be a movie library object ' do @@ -47,9 +49,9 @@ end it 'should calculate the average rating by year when the library has' do - movie_library.catalog(Movie.new(id: "the-id", title: "the-title", year: 1998, score: 50)) - movie_library.catalog(Movie.new(id: "the-id", title: "the-title", year: 2000, score: 50)) - movie_library.catalog(Movie.new(id: "the-id", title: "the-title", year: 1998, score: 50)) + movie_library.catalog(movie) + movie_library.catalog(another_movie) + movie_library.catalog(yet_another_movie) movie_library.average_rating_by_year(1998).should eq(50) end end @@ -57,21 +59,17 @@ describe "#sort_by_year" do it 'should sort the movies by year' do - another_movie = Movie.new(id: "the-id", title: "the-title", year: 2012, score: 50) - yet_another_movie = Movie.new(id: "the-id", title: "the-title", year: 1990, score: 45) movie_library.catalog(another_movie) movie_library.catalog(yet_another_movie) - movie_library.sort_by_year.should == [yet_another_movie, another_movie] + movie_library.library.should == [yet_another_movie, another_movie] end end describe "#calculate_slope" do it 'should calculate the slope of the average ratings from the first year to the last year' do - another_movie = Movie.new(id: "the-id", title: "the-title", year: 2012, score: 50) - yet_another_movie = Movie.new(id: "the-id", title: "the-title", year: 1990, score: 45) movie_library.catalog(another_movie) movie_library.catalog(yet_another_movie) - movie_library.calculate_slope.should eq(-0.22727272727272727) + movie_library.slope.should eq(-0.22727272727272727) end end end From cb1e2c075cc7ef88bc02efd66c0da04add2ef776 Mon Sep 17 00:00:00 2001 From: drammopo Date: Sat, 22 Feb 2014 19:05:39 +0200 Subject: [PATCH 19/23] Added program summary and one movie slope test. --- lib/movie_library.rb | 1 + movie_json.rb | 14 ++++++++++++-- spec/movie_library_spec.rb | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/movie_library.rb b/lib/movie_library.rb index 971bd10..e4b83c1 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -10,6 +10,7 @@ def initialize def calculate_slope(catalog) first = catalog.first last = catalog.last + return 0 if first == last (first.score - last.score).to_f / (last.year - first.year).to_f end diff --git a/movie_json.rb b/movie_json.rb index 0014abc..6d10bfe 100644 --- a/movie_json.rb +++ b/movie_json.rb @@ -14,19 +14,29 @@ def find_movie movie_library = MovieLibrary.new movie = find_movie +unless movie.nil? movie_library.catalog(movie) puts "Found: #{movie.title}. Score: #{movie.score}" -puts "The average rating for all movies searched thus far is #{movie_library.average_rating}." +end while true do puts "Search Again (Y/N)" answer = gets.upcase[0] if answer == "Y" movie = find_movie + unless movie.nil? movie_library.catalog(movie) puts "Found: #{movie.title}. Score: #{movie.score}" - puts "The average rating for all movies searched thus far is #{movie_library.average_rating}." + end else + puts "\n--------------------------" + puts "Summary for your Movie Library" + puts "-----------------------------" + movie_library.library.each do |movie| + puts "ID: #{movie.id}\tMovie: #{movie.title}\tYear: #{movie.year} Score: #{movie.score}\tAverage: #{movie_library.average_rating_by_year(movie.year)}" + end + puts "Your library has a Happiness Index of: #{movie_library.slope}" + puts "Goodbye!!!" break end end diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb index 19ab6eb..818c26b 100644 --- a/spec/movie_library_spec.rb +++ b/spec/movie_library_spec.rb @@ -66,10 +66,16 @@ end describe "#calculate_slope" do + + it "should have no slope when the library only contains one movie" do + movie_library.catalog(movie) + movie_library.slope.should eq(0) + end it 'should calculate the slope of the average ratings from the first year to the last year' do movie_library.catalog(another_movie) movie_library.catalog(yet_another_movie) movie_library.slope.should eq(-0.22727272727272727) end + end end From f9814fd8765b0df262d6093fa95ccb60176fea7b Mon Sep 17 00:00:00 2001 From: drammopo Date: Tue, 25 Feb 2014 17:49:33 +0200 Subject: [PATCH 20/23] Removed the use of unless as a 1 statement modifier. --- movie_json.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/movie_json.rb b/movie_json.rb index 6d10bfe..aa916b5 100644 --- a/movie_json.rb +++ b/movie_json.rb @@ -14,9 +14,9 @@ def find_movie movie_library = MovieLibrary.new movie = find_movie -unless movie.nil? -movie_library.catalog(movie) -puts "Found: #{movie.title}. Score: #{movie.score}" +if movie + movie_library.catalog(movie) + puts "Found: #{movie.title}. Score: #{movie.score}" end while true do @@ -24,9 +24,9 @@ def find_movie answer = gets.upcase[0] if answer == "Y" movie = find_movie - unless movie.nil? - movie_library.catalog(movie) - puts "Found: #{movie.title}. Score: #{movie.score}" + if movie + movie_library.catalog(movie) + puts "Found: #{movie.title}. Score: #{movie.score}" end else puts "\n--------------------------" From a93af62ba9944827846ddcc0d11b7fc3252d2dad Mon Sep 17 00:00:00 2001 From: drammopo Date: Tue, 25 Feb 2014 18:03:58 +0200 Subject: [PATCH 21/23] Refactored the use of instance variables and rename the catalog method. --- lib/movie_library.rb | 20 ++++++++++---------- spec/movie_library_spec.rb | 26 +++++++++++++------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/movie_library.rb b/lib/movie_library.rb index e4b83c1..a79bdb8 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -1,21 +1,22 @@ class MovieLibrary - attr_reader :movies, :library, :slope + attr_reader :movies, :catalog, :slope + attr_accessor :slope def initialize @movies = [] - @library = [] + @catalog = [] @slope = 0 end def calculate_slope(catalog) first = catalog.first last = catalog.last - return 0 if first == last - (first.score - last.score).to_f / (last.year - first.year).to_f + return 0 if catalog.count <= 1 + @slope = (first.score - last.score).to_f / (last.year - first.year).to_f end def sort_by_year(movies) - movies.sort { |movie,another_movie| movie.year <=> another_movie.year } + @catalog = movies.sort { |movie,another_movie| movie.year <=> another_movie.year } end def average_rating_by_year(year) @@ -27,11 +28,10 @@ def average_rating(movies) movies.inject(0.0) { |sum, movie| sum + movie.score } / movies.size end - def catalog(movie) - @movies << movie - @library = sort_by_year(@movies) - @slope = calculate_slope(@library) - return @library + def add(movie) + movies << movie + catalog = sort_by_year(movies) + calculate_slope(catalog) end def all_movies diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb index 818c26b..ad12d74 100644 --- a/spec/movie_library_spec.rb +++ b/spec/movie_library_spec.rb @@ -18,14 +18,14 @@ end end - describe "#catalog" do + describe "#add" do it 'should add a new movie to the library whenever a search happens' do - movie_library.catalog(movie) + movie_library.add(movie) expect(movie_library.all_movies).to include (movie) end it 'should increase the movie count' do - movie_library.catalog(movie) + movie_library.add(movie) movie_library.count.should eq(1) end end @@ -37,7 +37,7 @@ end it 'should calculate the average rating' do - movie_library.catalog(movie) + movie_library.add(movie) movie_library.average_rating(movie_library.all_movies).should eq(50) end end @@ -49,9 +49,9 @@ end it 'should calculate the average rating by year when the library has' do - movie_library.catalog(movie) - movie_library.catalog(another_movie) - movie_library.catalog(yet_another_movie) + movie_library.add(movie) + movie_library.add(another_movie) + movie_library.add(yet_another_movie) movie_library.average_rating_by_year(1998).should eq(50) end end @@ -59,21 +59,21 @@ describe "#sort_by_year" do it 'should sort the movies by year' do - movie_library.catalog(another_movie) - movie_library.catalog(yet_another_movie) - movie_library.library.should == [yet_another_movie, another_movie] + movie_library.add(another_movie) + movie_library.add(yet_another_movie) + movie_library.catalog.should == [yet_another_movie, another_movie] end end describe "#calculate_slope" do it "should have no slope when the library only contains one movie" do - movie_library.catalog(movie) + movie_library.add(movie) movie_library.slope.should eq(0) end it 'should calculate the slope of the average ratings from the first year to the last year' do - movie_library.catalog(another_movie) - movie_library.catalog(yet_another_movie) + movie_library.add(another_movie) + movie_library.add(yet_another_movie) movie_library.slope.should eq(-0.22727272727272727) end From 10a00eace06284f936209f6bc0e91dfc90b1b228 Mon Sep 17 00:00:00 2001 From: drammopo Date: Tue, 25 Feb 2014 21:01:13 +0200 Subject: [PATCH 22/23] Removed verbose calls to catalog. --- lib/movie_library.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/movie_library.rb b/lib/movie_library.rb index a79bdb8..10f78c2 100644 --- a/lib/movie_library.rb +++ b/lib/movie_library.rb @@ -30,8 +30,7 @@ def average_rating(movies) def add(movie) movies << movie - catalog = sort_by_year(movies) - calculate_slope(catalog) + calculate_slope sort_by_year(movies) end def all_movies From 2e367b853176bab78fc5c3452ab08ef0f3b75334 Mon Sep 17 00:00:00 2001 From: drammopo Date: Thu, 3 Apr 2014 19:32:36 +0200 Subject: [PATCH 23/23] Added fixes inline with renamed methods --- movie_json.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/movie_json.rb b/movie_json.rb index aa916b5..7c3eb29 100644 --- a/movie_json.rb +++ b/movie_json.rb @@ -15,7 +15,7 @@ def find_movie movie_library = MovieLibrary.new movie = find_movie if movie - movie_library.catalog(movie) + movie_library.add(movie) puts "Found: #{movie.title}. Score: #{movie.score}" end @@ -25,14 +25,14 @@ def find_movie if answer == "Y" movie = find_movie if movie - movie_library.catalog(movie) + movie_library.add(movie) puts "Found: #{movie.title}. Score: #{movie.score}" end else puts "\n--------------------------" puts "Summary for your Movie Library" puts "-----------------------------" - movie_library.library.each do |movie| + movie_library.all_movies.each do |movie| puts "ID: #{movie.id}\tMovie: #{movie.title}\tYear: #{movie.year} Score: #{movie.score}\tAverage: #{movie_library.average_rating_by_year(movie.year)}" end puts "Your library has a Happiness Index of: #{movie_library.slope}"