Class: ListLister

Inherits:
Runnable show all
Defined in:
lib/s3-object-processor.rb

Instance Method Summary collapse

Methods inherited from Runnable

#join, #on_finish

Constructor Details

#initialize(bucket, key_queue, max_keys = nil) ⇒ ListLister

Returns a new instance of ListLister.



67
68
69
70
71
# File 'lib/s3-object-processor.rb', line 67

def initialize(bucket, key_queue, max_keys = nil)
	@bucket = bucket
	@key_queue = key_queue
	@max_keys = max_keys
end

Instance Method Details

#on_keys_chunk(&callback) ⇒ Object



73
74
75
76
# File 'lib/s3-object-processor.rb', line 73

def on_keys_chunk(&callback)
	@on_keys_chunk = callback
	self
end

#run(list) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/s3-object-processor.rb', line 78

def run(list)
	super() do
		total_keys = 0
		@on_keys_chunk.call(list) if @on_keys_chunk
		list.each do |key|
			@key_queue << @bucket.key(key)
			break if @max_keys and total_keys >= @max_keys
			total_keys += 1
		end
	end
end