Sha256: 3c819a70b9aacf43fb59e0b998c01cb1633c44ba82b31424466221be54c1e641

Contents?: true

Size: 276 Bytes

Versions: 3

Compression:

Stored size: 276 Bytes

Contents

module HyperIterator
  def each_slice!(slice_size, &blk)
    i = 0

    while count > 0
      current_slice = []
      while i < slice_size && count > 0
        current_slice << shift
        i += 1
      end
      blk.call(current_slice)
      i = 0
    end
    nil
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hyper_iterator-0.2.2 lib/iterators/each_slice_bang.rb
hyper_iterator-0.2.1 lib/iterators/each_slice_bang.rb
hyper_iterator-0.2.0 lib/iterators/each_slice_bang.rb