summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Peasley <stephenpeasley@hotmail.com>2013-09-25 19:33:37 -0600
committerStephen Peasley <stephenpeasley@hotmail.com>2013-09-25 19:33:37 -0600
commit8cd43349bc932c3d7473f84a8766c370eb7f35b5 (patch)
tree0da5a78daaef23698e9b9278b30e369d12742c46
parentc66bc6a180c864a6012021caef650c2659f49bfc (diff)
tiny bit of refactoring.
-rw-r--r--spec/lesson_three/movie_library_spec.rb16
1 files changed, 7 insertions, 9 deletions
diff --git a/spec/lesson_three/movie_library_spec.rb b/spec/lesson_three/movie_library_spec.rb
index 47254e4..d04fe50 100644
--- a/spec/lesson_three/movie_library_spec.rb
+++ b/spec/lesson_three/movie_library_spec.rb
@@ -6,19 +6,17 @@ class Movie
end
end
-
class MovieLibrary
- attr_accessor :total_count
- def initialize(total_count = 0)
- @total_count = total_count
- @array_of_movies = []
+ def initialize(movies = [])
+ @movies = movies
end
def add(movie)
- if !@array_of_movies.include? movie
- @array_of_movies.push movie
- @total_count+=1
- end
+ @movies.push(movie) unless @movies.include? movie
+ end
+
+ def total_count
+ @movies.size
end
end