Module: EventMachine::IteratorWithEnumerable
- Included in:
- Iterator
- Defined in:
- lib/patch/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.
- #next_item ⇒ Object
- #setup_list(list) ⇒ Object
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
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/patch/iterator.rb', line 57 def next? begin @next_item = @list.next true rescue StopIteration false rescue => e raise e end end |
#next_item ⇒ Object
51 52 53 |
# File 'lib/patch/iterator.rb', line 51 def next_item @next_item end |
#setup_list(list) ⇒ Object
46 47 48 49 |
# File 'lib/patch/iterator.rb', line 46 def setup_list(list) raise ArgumentError, 'argument must be an Enumerable' unless list.respond_to?(:each) list.to_enum end |