Suppose I have an array
array = [1,2,3]
I need to create such a enumerator that will return values in cyclic manner:
array.next #=> 1
array.next #=> 2
array.next #=> 3
array.next #=> 1
array.next #=> 2
...
I believe there's a neat solution for that
Array#cycle/Enumerable#cycledoes what you are looking for:(1..3).cyclereturns equivalent values.