class AliyunSDK::OSS::Iterator::Base
Iterator
base that stores fetched results and fetch more if needed.
Public Class Methods
new(protocol, opts = {})
click to toggle source
# File lib/aliyun_sdk/oss/iterator.rb, line 14 def initialize(protocol, opts = {}) @protocol = protocol @results, @more = [], opts end
Public Instance Methods
next() { |r| ... }
click to toggle source
# File lib/aliyun_sdk/oss/iterator.rb, line 19 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()
click to toggle source
# File lib/aliyun_sdk/oss/iterator.rb, line 32 def to_enum self.enum_for(:next) end
Private Instance Methods
fetch_more()
click to toggle source
# File lib/aliyun_sdk/oss/iterator.rb, line 37 def fetch_more return if @more[:truncated] == false fetch(@more) end