Class: AWS::S3::Tree::LeafNode

Inherits:
Node
  • Object
show all
Defined in:
lib/aws/s3/tree/leaf_node.rb

Overview

Note:

Generally you do not need to create leaf nodes

Represents a leaf in an AWS::S3::Tree.

When enumerating nodes in an S3 tree, keys are yielded as leaf nodes (they have no children beneath them).

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, member) ⇒ LeafNode

Returns a new instance of LeafNode.



28
29
30
31
32
# File 'lib/aws/s3/tree/leaf_node.rb', line 28

def initialize parent, member
  @parent = parent
  @member = member
  super()
end

Instance Attribute Details

#membermixed (readonly)

Returns the object this leaf node represents.

Returns:

  • (mixed)

    Returns the object this leaf node represents.

See Also:



41
42
43
# File 'lib/aws/s3/tree/leaf_node.rb', line 41

def member
  @member
end

#parentTree, BranchNode (readonly)

Returns The parent node in the tree.

Returns:



35
36
37
# File 'lib/aws/s3/tree/leaf_node.rb', line 35

def parent
  @parent
end

Instance Method Details

#branch?false

Returns:

  • (false)


49
50
51
# File 'lib/aws/s3/tree/leaf_node.rb', line 49

def branch?
  false
end

#inspectObject



87
88
89
# File 'lib/aws/s3/tree/leaf_node.rb', line 87

def inspect
  "<#{self.class}:#{@member.bucket.name}:#{key}>"
end

#keyString

Returns the key this leaf node represents.

Returns:

  • (String)

    the key this leaf node represents.



44
45
46
# File 'lib/aws/s3/tree/leaf_node.rb', line 44

def key
  @member.key
end

#leaf?true

Returns:

  • (true)


54
55
56
# File 'lib/aws/s3/tree/leaf_node.rb', line 54

def leaf?
  true
end

#objectS3Object

Returns The object this leaf node represents.

Returns:

  • (S3Object)

    The object this leaf node represents.



59
60
61
62
63
64
65
# File 'lib/aws/s3/tree/leaf_node.rb', line 59

def object
  if @member.kind_of?(S3Object)
    @member
  else
    @member.object
  end
end

#uploadMultipartUpload

Returns the object version this leaf node represents.

Returns:

  • (MultipartUpload)

    Returns the object version this leaf node represents.



79
80
81
82
83
84
85
# File 'lib/aws/s3/tree/leaf_node.rb', line 79

def upload
  if @member.kind_of?(MultipartUpload)
    @member
  else
    raise "This leaf does not represent an upload"
  end
end

#versionObjectVersion

Returns the object version this leaf node represents.

Returns:

  • (ObjectVersion)

    Returns the object version this leaf node represents.



69
70
71
72
73
74
75
# File 'lib/aws/s3/tree/leaf_node.rb', line 69

def version
  if @member.kind_of?(ObjectVersion)
    @member
  else
    raise "This leaf does not represent a version"
  end
end