Sha256: c1ca6523738dab47e29b36fc2ea83252579f5ba67d49eb8c16317d49ec35c159

Contents?: true

Size: 589 Bytes

Versions: 2

Compression:

Stored size: 589 Bytes

Contents

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
      loop do
        link, from_page = @link_queue.deq
        
        break if link == :END

        @page_queue.enq @http.fetch_page(link, from_page)

        sleep Anemone.options.delay
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
anemone-0.2.2 lib/anemone/tentacle.rb
anemone-0.2.1 lib/anemone/tentacle.rb