lib/anemone/tentacle.rb in anemone-0.2.2 vs lib/anemone/tentacle.rb in anemone-0.2.3
- old
+ new
@@ -4,14 +4,15 @@
class Tentacle
#
# Create a new Tentacle
#
- def initialize(link_queue, page_queue)
+ def initialize(link_queue, page_queue, opts = {})
@link_queue = link_queue
@page_queue = page_queue
- @http = Anemone::HTTP.new
+ @http = Anemone::HTTP.new(opts)
+ @opts = opts
end
#
# Gets links from @link_queue, and returns the fetched
# Page objects into @page_queue
@@ -20,13 +21,19 @@
loop do
link, from_page = @link_queue.deq
break if link == :END
- @page_queue.enq @http.fetch_page(link, from_page)
+ @page_queue << @http.fetch_page(link, from_page)
- sleep Anemone.options.delay
+ delay
end
+ end
+
+ private
+
+ def delay
+ sleep @opts[:delay] if @opts[:delay]
end
end
end
\ No newline at end of file