Class: Alipan::Iterator::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/alipan/iterator.rb

Direct Known Subclasses

Objects

Instance Method Summary collapse

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

#nextObject



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_enumObject



23
24
25
# File 'lib/alipan/iterator.rb', line 23

def to_enum
  self.enum_for(:next)
end