class SyncEnum
Allows a collection of enumerators to be iterated over in parallel, using the same call to next as a normal enumerator.
Constants
- VERSION
The version number for sync_enum.
Public Class Methods
Returns a new SyncEnum
, containing each of the enumerators provided as arguments to new.
Parameters¶ ↑
-
*enums - each argument is a distinct enumerator, and the returned arrays of values are ordered exactly as the enumerators are in the argument list.
# File lib/sync_enum/sync_enum.rb, line 16 def initialize(*enums) @enum_bank = enums end
Public Instance Methods
Returns an array containing the next set of values. The first value in the returned array is the next element of the first enumerator, the second value in the returned array is the next element of the second enumerator, and so forth.
A StopIteration exception is raised as soon as next is called and one of the enumerators is out of elements. If no enumerators were provided to the constructor, StopIteration is raised on the first call to next.
# File lib/sync_enum/sync_enum.rb, line 31 def next raise StopIteration if @enum_bank.empty? @enum_bank.map(&:next) end