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.



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

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

Instance Attribute Details

#objectsObject (readonly)

Returns the value of attribute objects.



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

def objects
  @objects
end

Instance Method Details

#fetch!Object



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

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