Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/magellan/extensions/array.rb

Instance Method Summary collapse

Instance Method Details

#chunk(max_size) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/magellan/extensions/array.rb', line 2

def chunk(max_size)
  result = []
  number_of_chunks = (self.size.to_f / max_size).ceil
  for i in 0...number_of_chunks do
    result << self[i*max_size...(i+1)*max_size]
  end
  result
end