Sha256: b6cd69619ada2448c7e99cb59667092fc079626a64bca8940bc6c2c80bf7a672

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

require 'anemone/page'

module Anemone
  class Tentacle
    
    #
    # Create a new Tentacle
    #
    def initialize(link_queue, page_queue)
      @link_queue = link_queue
      @page_queue = page_queue
    end
    
    #
    # Gets links from @link_queue, and returns the fetched
    # Page objects into @page_queue
    #
    def run
      while true 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)

        sleep Anemone.options.delay
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
anemone-0.2.0 lib/anemone/tentacle.rb