Method: ArrayFloe::Array#each_with_index_floe

Defined in:
lib/array_floe/array.rb

#each_with_index_floeObject

For each element in the array, calls the block with three arguments: the element, its index, and a “floe” object.

ary.each_with_index_floe do |element, i, floe|
    assert_equal(i == 0,        floe.first?)
    assert_equal(i == ary.last, floe.last?)
    assert_equal(i % 2 == 1,    float.odd?)
    assert_equal(i % 2 == 1,    float.even?)
end

If no block is given, an enumerator is returned instead.



46
47
48
49
50
51
52
53
54
# File 'lib/array_floe/array.rb', line 46

def each_with_index_floe() # :yields: element, i, floe
  if block_given?
    each_with_index do |element, i|
      yield(element, i, Floe.new(i, size))
    end
  else
    to_enum(:each_with_index_floe)
  end
end