Class: AWS::S3::Tree::ChildCollection
- Inherits:
-
Object
- Object
- AWS::S3::Tree::ChildCollection
- Includes:
- Enumerable
- Defined in:
- lib/aws/s3/tree/child_collection.rb
Instance Attribute Summary collapse
-
#collection ⇒ ObjectCollection, ...
readonly
Returns the collection this tree is based on.
-
#delimiter ⇒ String
readonly
When looking at S3 keys as a tree, the delimiter defines what string pattern seperates each level of the tree.
-
#parent ⇒ Tree, BranchNode
readonly
The parent node in the tree.
-
#prefix ⇒ String?
readonly
A tree may have a prefix of where in the bucket to be based from.
Instance Method Summary collapse
-
#append? ⇒ Boolean
Returns true if the tree is set to auto-append the delimiter to the prefix when the prefix does not end with the delimiter.
-
#each {|tree_node| ... } ⇒ nil
Yields up branches and leaves.
Instance Attribute Details
#collection ⇒ ObjectCollection, ... (readonly)
Returns the collection this tree is based on.
52 53 54 |
# File 'lib/aws/s3/tree/child_collection.rb', line 52 def collection @collection end |
#delimiter ⇒ String (readonly)
When looking at S3 keys as a tree, the delimiter defines what string pattern seperates each level of the tree. The delimiter defaults to ‘/’ (like in a file system).
62 63 64 |
# File 'lib/aws/s3/tree/child_collection.rb', line 62 def delimiter @delimiter end |
#parent ⇒ Tree, BranchNode (readonly)
Returns The parent node in the tree.
47 48 49 |
# File 'lib/aws/s3/tree/child_collection.rb', line 47 def parent @parent end |
#prefix ⇒ String? (readonly)
A tree may have a prefix of where in the bucket to be based from.
56 57 58 |
# File 'lib/aws/s3/tree/child_collection.rb', line 56 def prefix @prefix end |
Instance Method Details
#append? ⇒ Boolean
Returns true if the tree is set to auto-append the delimiter to the prefix when the prefix does not end with the delimiter.
67 68 69 |
# File 'lib/aws/s3/tree/child_collection.rb', line 67 def append? @append end |
#each {|tree_node| ... } ⇒ nil
Yields up branches and leaves.
A branch node represents a common prefix (like a directory) and a leaf node represents a key (S3 object).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/aws/s3/tree/child_collection.rb', line 79 def each &block collection = self.collection if prefix = prefix_with_delim collection = collection.with_prefix(prefix) end collection.each(:delimiter => delimiter) do |member| case when member.respond_to?(:key) yield LeafNode.new(parent, member) when member.respond_to?(:prefix) yield BranchNode.new(parent, member, :delimiter => delimiter, :append => append?) end end nil end |