Module: EventMachine::IteratorWithEnumerable
- Included in:
- Iterator
- Defined in:
- lib/em/iterator.rb
Overview
Support for Enumerable in Ruby 1.9+
Instance Method Summary collapse
-
#next? ⇒ Boolean
We can't check just next_item as far as it can return nil in two cases: when our enumerator is stopped and when it stores nil value.
-
#setup_list(list) ⇒ Object
In case of Enumerable object we can use lazyness of Enumerator.
Instance Method Details
#next? ⇒ Boolean
We can't check just next_item as far as it can return nil in two cases: when our enumerator is stopped and when it stores nil value
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/em/iterator.rb', line 36 def next? begin @next_item = @list.next true rescue StopIteration false rescue => e raise e end end |
#setup_list(list) ⇒ Object
In case of Enumerable object we can use lazyness of Enumerator
29 30 31 32 |
# File 'lib/em/iterator.rb', line 29 def setup_list(list) raise ArgumentError, 'argument must be an Enumerable' unless list.respond_to?(:each) list.to_enum end |