lib/iteration.rb in iteration-1.1.0 vs lib/iteration.rb in iteration-1.1.1

- old
+ new

@@ -28,11 +28,11 @@ enum.slice(index+1..-1) end #private - # TODO: For Ruby 1.9 make private and use fcall. + # TODO: For Ruby 1.9 make private and use fcall ? # def __step__(value, &block) @value = value block.call @index += 1 @@ -59,11 +59,11 @@ each do |e| it.__step__(e){ yield(it) } end end - def with_iteration(&block) + def with_iteration(&block) #:yield: it = Iteration.new(self) each do |e| it.__step__(e){ yield(e,it) } end end @@ -81,21 +81,20 @@ # p it.last? # p it.prior # p it.after # end # - # on each successive iteration produces: + # On each successive iteration this produces: # # 0 1 2 # 1 2 3 # true false false # false false true # [] [1] [1,2] # [2,3] [3] [] # - # CREDIT: Trans - + # @return [Enumerator] if no block is given, otherwise nothing. def each_iteration(&block) if block_given? it = Iteration.new(self) each do |e| it.__step__(e){ yield(it) } @@ -106,18 +105,18 @@ end # Same as #each_iteration, but provides both the iterated # element and the iteration. # + # @return [Enumerator] if no block is given, otherwise nothing. def each_with_iteration(&block) if block_given? it = Iteration.new(self) each do |e| it.__step__(e){ yield(e, it) } end else - Enumerator.new(self, :each_iteration) + Enumerator.new(self, :each_with_iteration) end end end -