class Drophunter::Worker
Constants
- ALLOWED_CHARS
Public Instance Methods
default_strategy()
click to toggle source
# File lib/drophunter/worker.rb, line 21 def default_strategy ALLOWED_CHARS.repeated_permutation(4).each do |id_as_array| save_file(id_as_array.join) end end
random_strategy(&block)
click to toggle source
# File lib/drophunter/worker.rb, line 27 def random_strategy(&block) Enumerator.new do |enumerator| loop do enumerator.yield(4.times.map { ALLOWED_CHARS[Random.rand(0..ALLOWED_CHARS.length)] }.join) end end.each { |id| block.call(id) } end
run()
click to toggle source
# File lib/drophunter/worker.rb, line 11 def run send("#{strategy || :default}_strategy") end
save_file(id)
click to toggle source
# File lib/drophunter/worker.rb, line 15 def save_file(id) default_saver = Drophunter::Savers::Local.new Drophunter::Page.new(id).save(Drophunter::FileTypes::Image, default_saver) end