class KXI::Collections::ArrayCollection::ArrayEnumerator

Enumerates array

Public Class Methods

new(array) click to toggle source

Instantiates the {KXI::Collections::ArrayCollection::ArrayEnumerator} class @param array [Array] Array for enumeration

# File lib/kxi/collections/array_collection.rb, line 78
def initialize(array)
        @arr     = array
        @current = 0
end

Public Instance Methods

current() click to toggle source

Returns current item @return [Object] Current item

# File lib/kxi/collections/array_collection.rb, line 99
def current
        @arr[@current]
end
next() click to toggle source

Advances enumerator to next item @return [Bool] True if item is available; false otherwise

# File lib/kxi/collections/array_collection.rb, line 92
def next
        @current = @current + 1
        return @current < @arr.length
end
rewind() click to toggle source

Selects first item in collection @return [Bool] True if collection contains elements; otherwise false

# File lib/kxi/collections/array_collection.rb, line 85
def rewind
        @current = 0
        return @arr.length > 0
end