Class: Lowkiq::Utils::Array

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

Instance Method Summary collapse

Constructor Details

#initialize(array) ⇒ Array

Returns a new instance of Array.



4
5
6
# File 'lib/lowkiq/utils.rb', line 4

def initialize(array)
  @array = array.to_a
end

Instance Method Details

#in_transposed_groups(number) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/lowkiq/utils.rb', line 8

def in_transposed_groups(number)
  result = number.times.map { [] }

  @array.each_with_index do |item, index|
    group = index % number
    result[group] << item
  end

  result
end