Class: S3::ObjectCollection
- Inherits:
-
Driver::Model
- Object
- Driver::Model
- S3::ObjectCollection
- Includes:
- Enumerable
- Defined in:
- lib/s3/client/model/object_collection.rb
Instance Method Summary collapse
- #[](object_name) ⇒ Object
- #each ⇒ Object
-
#initialize(api, bucket_name) ⇒ ObjectCollection
constructor
A new instance of ObjectCollection.
- #where(prefix: nil, delimiter: nil) ⇒ Object
Constructor Details
#initialize(api, bucket_name) ⇒ ObjectCollection
Returns a new instance of ObjectCollection.
5 6 7 8 |
# File 'lib/s3/client/model/object_collection.rb', line 5 def initialize(api, bucket_name) super(api) @bucket = bucket_name end |
Instance Method Details
#[](object_name) ⇒ Object
10 11 12 |
# File 'lib/s3/client/model/object_collection.rb', line 10 def [](object_name) object_named(object_name) end |
#each ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/s3/client/model/object_collection.rb', line 21 def each = {} if @prefix = .merge(prefix: @prefix) end if @delimiter = .merge(delimiter: @delimiter) end marker = nil truncated = false begin if marker.present? = .merge(marker: marker) end xml_doc = @api.objects(@bucket, ) objects_result = S3::Concerns::ObjectsResult.new(xml_doc) objects = objects_result.full_objects truncated = objects_result.truncated? next_marker = objects_result.next_marker if next_marker.nil? marker = objects.last['Key'][0] if objects.present? else marker = next_marker end objects.each do |object| yield object_opts(object) end end while truncated end |
#where(prefix: nil, delimiter: nil) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/s3/client/model/object_collection.rb', line 14 def where(prefix: nil, delimiter: nil) @prefix = prefix @delimiter = delimiter self end |