lib/anemone/tentacle.rb in anemone-0.2.0 vs lib/anemone/tentacle.rb in anemone-0.2.1
- old
+ new
@@ -1,37 +1,32 @@
-require 'anemone/page'
+require 'anemone/http'
module Anemone
class Tentacle
#
# Create a new Tentacle
#
def initialize(link_queue, page_queue)
@link_queue = link_queue
@page_queue = page_queue
+ @http = Anemone::HTTP.new
end
#
# Gets links from @link_queue, and returns the fetched
# Page objects into @page_queue
#
def run
- while true do
+ loop do
link, from_page = @link_queue.deq
break if link == :END
-
- if from_page
- page = Page.fetch(link, from_page)
- else
- page = Page.fetch(link)
- end
-
- @page_queue.enq(page)
+ @page_queue.enq @http.fetch_page(link, from_page)
+
sleep Anemone.options.delay
end
end
-
+
end
end
\ No newline at end of file