Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/scrapescrobbler/helpers.rb
Instance Method Summary collapse
Instance Method Details
#chunk(chunk_size) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/scrapescrobbler/helpers.rb', line 2 def chunk(chunk_size) chunks = [self.length / chunk_size, 1].max.times.collect { [] } while self.any? chunks.each do |a_chunk| chunk_size.times do a_chunk << self.shift if self.any? end end end chunks end |