Class: S3Utils::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_utils/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Generator

Returns a new instance of Generator.



3
4
5
# File 'lib/s3_utils/generator.rb', line 3

def initialize(path)
  @path = Path.new(path)
end

Instance Method Details

#bucketObject



7
8
9
# File 'lib/s3_utils/generator.rb', line 7

def bucket
  s3.buckets[@path.bucket_name]
end

#s3_object(path = nil) ⇒ Object



11
12
13
14
15
# File 'lib/s3_utils/generator.rb', line 11

def s3_object(path=nil)
  base_path = @path.path_without_bucket
  dest_path = path ? File.join(base_path, path) : base_path
  bucket.objects[dest_path]
end

#s3_object_collection(path = nil) ⇒ Object



17
18
19
20
# File 'lib/s3_utils/generator.rb', line 17

def s3_object_collection(path=nil)
  base_path = @path.path_without_bucket
  bucket.objects.with_prefix(base_path)
end

#treeObject



22
23
24
# File 'lib/s3_utils/generator.rb', line 22

def tree
  bucket.as_tree(prefix: @path.path_without_bucket)
end