Class: Uplink::UploadPartIterator

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

Instance Method Summary collapse

Constructor Details

#initialize(upload_part_iterator) ⇒ UploadPartIterator

Returns a new instance of UploadPartIterator.



183
184
185
# File 'lib/uplink/upload.rb', line 183

def initialize(upload_part_iterator)
  @upload_part_iterator = upload_part_iterator
end

Instance Method Details

#itemObject



201
202
203
204
205
206
# File 'lib/uplink/upload.rb', line 201

def item
  upload_part = UplinkLib.uplink_part_iterator_item(@upload_part_iterator)
  UploadPart.new(nil, upload_part)
ensure
  UplinkLib.uplink_free_part(upload_part) if upload_part
end

#next?Boolean

Returns:

  • (Boolean)


187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/uplink/upload.rb', line 187

def next?
  has_next = UplinkLib.uplink_part_iterator_next(@upload_part_iterator)
  unless has_next
    begin
      error = UplinkLib.uplink_part_iterator_err(@upload_part_iterator)
      ErrorUtil.handle_error(error)
    ensure
      UplinkLib.uplink_free_error(error) if error
    end
  end

  has_next
end