Class: Aliyun::OSS::Iterator::Base
- Inherits:
-
Object
- Object
- Aliyun::OSS::Iterator::Base
- Defined in:
- lib/aliyun/oss/iterator.rb
Overview
Iterator base that stores fetched results and fetch more if needed.
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.
15 16 17 18 |
# File 'lib/aliyun/oss/iterator.rb', line 15 def initialize(protocol, opts = {}) @protocol = protocol @results, @more = [], opts end |
Instance Method Details
#next ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/aliyun/oss/iterator.rb', line 20 def next loop do # Communicate with the server to get more results fetch_more if @results.empty? # Return the first result r = @results.shift break unless r yield r end end |
#to_enum ⇒ Object
33 34 35 |
# File 'lib/aliyun/oss/iterator.rb', line 33 def to_enum self.enum_for(:next) end |