Class: Alipan::Iterator::Base
- Inherits:
-
Object
- Object
- Alipan::Iterator::Base
- Defined in:
- lib/alipan/iterator.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(protocol, opts = {}) ⇒ Base
constructor
A new instance of Base.
- #next ⇒ Object
- #to_enum ⇒ Object
Constructor Details
#initialize(protocol, opts = {}) ⇒ Base
Returns a new instance of Base.
7 8 9 10 |
# File 'lib/alipan/iterator.rb', line 7 def initialize(protocol, opts = {}) @protocol = protocol @results, @more = [], opts end |
Instance Method Details
#next ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/alipan/iterator.rb', line 12 def next loop do fetch_more if @results.empty? r = @results.shift break unless r yield r end end |
#to_enum ⇒ Object
23 24 25 |
# File 'lib/alipan/iterator.rb', line 23 def to_enum self.enum_for(:next) end |