lib/raap/sized.rb in raap-0.3.0 vs lib/raap/sized.rb in raap-0.4.0

- old
+ new

@@ -2,10 +2,11 @@ module RaaP class Sized def initialize(&block) raise LocalJumpError, "no block given" unless block + @block = block @such_that = nil end def pick(size:) @@ -26,9 +27,10 @@ skip = 0 while skip < 100 picked = yield(skip) such_that = @such_that return picked if such_that.nil? || such_that.call(picked) + skip += 1 raise "too many skips" unless skip < 100 end raise "never reached" end