Class: Ggggsss::S3Fetcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket_name, path) ⇒ S3Fetcher

Returns a new instance of S3Fetcher.



49
50
51
52
53
# File 'lib/ggggsss.rb', line 49

def initialize(bucket_name, path)
  @bucket_name = bucket_name
  @path = path
  @objects = []
end

Instance Attribute Details

#objectsObject (readonly)

Returns the value of attribute objects.



47
48
49
# File 'lib/ggggsss.rb', line 47

def objects
  @objects
end

Instance Method Details

#fetch!Object



55
56
57
58
59
60
61
62
# File 'lib/ggggsss.rb', line 55

def fetch!
  s3 = Aws::S3::Resource.new
  bucket = s3.bucket(@bucket_name)
  bucket.objects(prefix: @path).each do |object_summary|
    object_output = object_summary.get
    @objects << S3Object.new(key: object_summary.key, body: object_output.body)
  end
end