Class: Array

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

Instance Method Summary collapse

Instance Method Details

#in_groups_of(number, fill_with = nil, &block) ⇒ Object



825
826
827
828
829
830
# File 'lib/ruby_reflector.rb', line 825

def in_groups_of(number, fill_with = nil, &block)
require 'enumerator'
collection = dup
collection << fill_with until collection.size.modulo(number).zero?
collection.each_slice(number, &block)
end