Module: AWS::S3::Tree::Parent

Includes:
Core::Model
Included in:
AWS::S3::Tree, BranchNode
Defined in:
lib/aws/s3/tree/parent.rb

Overview

Common methods for tree nodes that are parents to other nodes (AWS::S3::Tree and BranchNode).

Instance Attribute Summary collapse

Attributes included from Core::Model

#config

Instance Method Summary collapse

Methods included from Core::Model

#client, #config_prefix

Instance Attribute Details

#collectionObjectCollection, ... (readonly)

Returns The collection whose members will be explored using the tree.

Returns:


46
47
48
# File 'lib/aws/s3/tree/parent.rb', line 46

def collection
  @collection
end

#delimiterString (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).

Returns:

  • (String)

60
61
62
# File 'lib/aws/s3/tree/parent.rb', line 60

def delimiter
  @delimiter
end

#prefixString? (readonly)

A tree may have a prefix of where in the bucket to be based from. A value of nil means that the tree will include all objects in the collection.

Returns:

  • (String, nil)

53
54
55
# File 'lib/aws/s3/tree/parent.rb', line 53

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.

Returns:

  • (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.


65
66
67
# File 'lib/aws/s3/tree/parent.rb', line 65

def append?
  @append
end

#childrenTree::ChildCollection

Returns A collection representing all the child nodes of this node. These may be either BranchNode objects or LeafNode objects.

Returns:


72
73
74
75
76
77
# File 'lib/aws/s3/tree/parent.rb', line 72

def children
  Tree::ChildCollection.new(self, collection,
                            :delimiter => delimiter,
                            :prefix => prefix,
                            :append => append?)
end

#initialize(collection, options = {}) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/aws/s3/tree/parent.rb', line 26

def initialize collection, options = {}

  options = {
    :prefix => nil,
    :delimiter => '/',
    :append => true,
  }.merge(options)

  @collection = collection
  @prefix = options[:prefix]
  @delimiter = options[:delimiter]
  @append = options[:append]

  super

end

#inspectObject


79
80
81
# File 'lib/aws/s3/tree/parent.rb', line 79

def inspect
  "<#{self.class}:#{collection.bucket.name}:#{prefix}>"
end