main
1require 'helpers'
2
3class MovieLibrary
4 include Helpers
5
6 def initialize(movies = [])
7 @movies = movies
8 end
9
10 def add(movie)
11 @movies.push(movie) unless include?(movie)
12 end
13
14 def total_count
15 @movies.size
16 end
17
18 def each
19 # @movies.count.times do |n|
20 # yield @movies[n]
21 # end
22
23 # n = 0
24 # loop do
25 # current = @movies[n]
26 # puts current
27 # return unless current
28 # yield current
29 # n += 1
30 # end
31
32 # for x in @movies
33 # yield x
34 # end
35
36 # i = 0
37 # current = @movies[i]
38 # while current do
39 # yield current
40 # current = @movies[i]
41 # i+=1
42 # end
43
44 # i = 0
45 # until i == @movies.count do
46 # yield @movies[i]
47 # i +=1
48 # end
49 #
50 #i =0
51 #yield @movies[i]; i+=1 until @movies.count==i
52 #
53
54 # puts "blah" while true
55 @movies.each do |movie|
56 yield movie
57 end
58 end
59end