Module: AWS::S3::PrefixedCollection
- Includes:
- PaginatedCollection
- Included in:
- PrefixAndDelimiterCollection
- Defined in:
- lib/aws/s3/prefixed_collection.rb
Instance Attribute Summary collapse
-
#prefix ⇒ String?
readonly
The prefix of this collection.
Attributes included from Core::Model
Instance Method Summary collapse
- #initialize(*args) ⇒ Object
-
#with_prefix(prefix, mode = :replace) ⇒ Collection
Returns a new collection with a different prefix.
Methods included from Core::Collection::Limitable
Methods included from Core::Collection
#each, #each_batch, #enum, #first, #in_groups_of, #page
Methods included from Core::Model
#client, #config_prefix, #inspect
Instance Attribute Details
#prefix ⇒ String? (readonly)
Returns The prefix of this collection.
30 31 32 |
# File 'lib/aws/s3/prefixed_collection.rb', line 30 def prefix @prefix end |
Instance Method Details
#initialize(*args) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/aws/s3/prefixed_collection.rb', line 22 def initialize *args = args.last.is_a?(Hash) ? args.pop : {} @prefix = [:prefix] args.push() super(*args) end |
#with_prefix(prefix, mode = :replace) ⇒ Collection
Returns a new collection with a different prefix
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/aws/s3/prefixed_collection.rb', line 59 def with_prefix prefix, mode = :replace new_prefix = case mode when :replace then prefix when :append then "#{@prefix}#{prefix}" when :prepend then "#{prefix}#{@prefix}" else raise ArgumentError, "invalid prefix mode `#{mode}`, it must be " + ":replace, :append or :prepend" end self.class.new(bucket, :prefix => new_prefix) end |