Class: Uplink::UploadIterator

Inherits:
Object
  • Object
show all
Defined in:
lib/uplink/upload.rb

Instance Method Summary collapse

Constructor Details

#initialize(upload_iterator) ⇒ UploadIterator

Returns a new instance of UploadIterator.



156
157
158
# File 'lib/uplink/upload.rb', line 156

def initialize(upload_iterator)
  @upload_iterator = upload_iterator
end

Instance Method Details

#itemObject



174
175
176
177
178
179
# File 'lib/uplink/upload.rb', line 174

def item
  upload_info = UplinkLib.uplink_upload_iterator_item(@upload_iterator)
  UploadInfo.new(nil, upload_info)
ensure
  UplinkLib.uplink_free_upload_info(upload_info) if upload_info
end

#next?Boolean

Returns:

  • (Boolean)


160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/uplink/upload.rb', line 160

def next?
  has_next = UplinkLib.uplink_upload_iterator_next(@upload_iterator)
  unless has_next
    begin
      error = UplinkLib.uplink_upload_iterator_err(@upload_iterator)
      ErrorUtil.handle_error(error)
    ensure
      UplinkLib.uplink_free_error(error) if error
    end
  end

  has_next
end