Sha256: 22557cfe88c7055c6b025797e4d9277d0f69805ce833dd427f1883dff73b0de2

Contents?: true

Size: 577 Bytes

Versions: 13

Compression:

Stored size: 577 Bytes

Contents

class ArrayUtil

  def self.to_columns(arr)
    if arr[0][0] == '*'
      "*#{StringUtil.backward_truncate(arr[0][1..])} | #{arr[1]}  #{arr[2]}\n"
    else
      " #{StringUtil.backward_truncate(arr[0])} | #{arr[1]}  #{arr[2]}\n"
    end
  end

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

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
web_translate_it-2.8.3 lib/web_translate_it/util/array_util.rb
web_translate_it-2.8.2 lib/web_translate_it/util/array_util.rb
web_translate_it-2.8.1 lib/web_translate_it/util/array_util.rb
web_translate_it-2.8.0 lib/web_translate_it/util/array_util.rb
web_translate_it-2.8.0.pre.1 lib/web_translate_it/util/array_util.rb
web_translate_it-2.7.6 lib/web_translate_it/util/array_util.rb
web_translate_it-2.7.5 lib/web_translate_it/util/array_util.rb
web_translate_it-2.7.4 lib/web_translate_it/util/array_util.rb
web_translate_it-2.7.3 lib/web_translate_it/util/array_util.rb
web_translate_it-2.7.2 lib/web_translate_it/util/array_util.rb
web_translate_it-2.7.1 lib/web_translate_it/util/array_util.rb
web_translate_it-2.7.0 lib/web_translate_it/util/array_util.rb
web_translate_it-2.6.4 lib/web_translate_it/util/array_util.rb