class Zeus::S3Iterate

Attributes

s3[R]

Public Class Methods

new(s3) click to toggle source
# File lib/zeus/s3_iterate.rb, line 10
def initialize(s3)
  @s3 = s3
end

Public Instance Methods

delete_if(bucket:, prefix:) { |file| ... } click to toggle source
# File lib/zeus/s3_iterate.rb, line 14
def delete_if(bucket:, prefix:)
  each_file(bucket: bucket, prefix: prefix) do |file|
    next unless yield(file)

    s3.delete_object(bucket: bucket, key: file.key)
  end
end
each_file(bucket:, prefix:) { |file| ... } click to toggle source
# File lib/zeus/s3_iterate.rb, line 22
def each_file(bucket:, prefix:)
  s3.list_objects_v2(bucket: bucket, prefix: prefix).each do |page|
    iterate(page) do |list|
      list.contents.each do |file|
        yield(file)
      end
    end
  end
end

Private Instance Methods

iterate(page) { |page| ... } click to toggle source

@param page [Seahorse::Client::Response]

# File lib/zeus/s3_iterate.rb, line 35
def iterate(page, &block)
  yield(page)
  iterate(page.next_page, &block) if page.next_page?
end