class TableUtils::LimitLoops

Attributes

total[R]

Public Class Methods

new(max_count) click to toggle source
# File lib/table_utils/limit_loops.rb, line 5
def initialize max_count
  @total = @left_count = max_count
end
to(max_count, &block) click to toggle source
# File lib/table_utils/limit_loops.rb, line 17
def self.to max_count, &block
  LimitLoops.new(max_count).limit &block
end

Public Instance Methods

check!() click to toggle source
# File lib/table_utils/limit_loops.rb, line 13
def check!
  throw self if @left_count and (@left_count -= 1) <= 0
end
limit() { |self| ... } click to toggle source
# File lib/table_utils/limit_loops.rb, line 9
def limit
  catch(self) { yield self }
end