Sha256: f49595911a77a7c7300e4a4300671a314a796e3c5adceb012af569d4d9b9de54

Contents?: true

Size: 410 Bytes

Versions: 54

Compression:

Stored size: 410 Bytes

Contents

class ArrayUtil
  def self.to_columns(arr)
    " #{StringUtil.backward_truncate(arr[0])} | #{arr[1]}  #{arr[2]}\n"
  end

  def self.chunk(arr, pieces=2)
    len = arr.length;
    mid = (len/pieces)
    chunks = []
    start = 0
    1.upto(pieces) do |i|
      last = start+mid
      last = last-1 unless len%pieces >= i
      chunks << arr[start..last] || []
      start = last+1
    end
    chunks
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
web_translate_it-2.2.0 lib/web_translate_it/util/array_util.rb
web_translate_it-2.1.8 lib/web_translate_it/util/array_util.rb
web_translate_it-2.1.7 lib/web_translate_it/util/array_util.rb
web_translate_it-2.1.6 lib/web_translate_it/util/array_util.rb
web_translate_it-2.1.5 lib/web_translate_it/util/array_util.rb
web_translate_it-2.1.4 lib/web_translate_it/util/array_util.rb
web_translate_it-2.1.3 lib/web_translate_it/util/array_util.rb
web_translate_it-2.1.2 lib/web_translate_it/util/array_util.rb
web_translate_it-2.1.1 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.8 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.7 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.6 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.5 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.4 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.3 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.2 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.1 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.0 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.0.rc4 lib/web_translate_it/util/array_util.rb
web_translate_it-2.0.0.rc3 lib/web_translate_it/util/array_util.rb