Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/core_extend/array.rb

Instance Method Summary collapse

Instance Method Details

#every(num = 1) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/core_extend/array.rb', line 3

def every(num=1)
  index = 0
  while self[index]
    yield(*(1..num).to_a.inject([]) { |acc, n| acc<<self[index+n-1] })
    index+=num
  end
end