Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/dump.rb

Instance Method Summary collapse

Instance Method Details

#chunk(number_of_chunks) ⇒ Object Also known as: /



284
285
286
287
288
289
290
# File 'lib/redis/dump.rb', line 284

def chunk(number_of_chunks)
  chunks = (1..number_of_chunks).collect { [] }
  chunks.each do |a_chunk|
    a_chunk << self.shift if self.any?
  end
  chunks
end

#tuple(tuple_size = 2) ⇒ Object



292
293
294
295
296
297
298
# File 'lib/redis/dump.rb', line 292

def tuple(tuple_size=2)
  tuples = (1..(size/tuple_size)).collect { [] }
  tuples.each_with_index do |a_tuple,idx|
    tuple_size.times { a_tuple << self.shift } if self.any?
  end
  tuples
end