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.4.12 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.11 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.10 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.9 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.8 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.7 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.6 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.5 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.4 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.3 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.2 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.1 lib/web_translate_it/util/array_util.rb
web_translate_it-2.4.0 lib/web_translate_it/util/array_util.rb
web_translate_it-2.3.4 lib/web_translate_it/util/array_util.rb
web_translate_it-2.3.3 lib/web_translate_it/util/array_util.rb
web_translate_it-2.3.2 lib/web_translate_it/util/array_util.rb
web_translate_it-2.3.1 lib/web_translate_it/util/array_util.rb
web_translate_it-2.3.0 lib/web_translate_it/util/array_util.rb
web_translate_it-2.2.2 lib/web_translate_it/util/array_util.rb
web_translate_it-2.2.1 lib/web_translate_it/util/array_util.rb