Sha256: 061948c1f8276e15ccaffc06e49d6b27976c84de5b89e49c56e110af8466e149

Contents?: true

Size: 329 Bytes

Versions: 8

Compression:

Stored size: 329 Bytes

Contents

class Array
  #
  # TODO 
  # active_supportに同様のメソッドが無いかどうかの確認
  #
  def split_by(num)
    return [] if self.size < 1
    ret = [[]]
    counter = 0
    self.each do |val|
      (counter = 0;ret << []) if counter >= num
      ret[-1] << val
      counter += 1
    end
    return ret
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kanamei-keystone-0.0.18 lib/keystone/core_ext/array.rb
kanamei-keystone-0.0.19 lib/keystone/core_ext/array.rb
kanamei-keystone-0.0.20 lib/keystone/core_ext/array.rb
kanamei-keystone-0.0.21 lib/keystone/core_ext/array.rb
kanamei-keystone-0.0.22 lib/keystone/core_ext/array.rb
kanamei-keystone-0.0.23 lib/keystone/core_ext/array.rb
kanamei-keystone-0.0.24 lib/keystone/core_ext/array.rb
kanamei-keystone-0.0.25 lib/keystone/core_ext/array.rb