Class: Snapcrawl::Crawler

Inherits:
Object
  • Object
show all
Defined in:
lib/snapcrawl/crawler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Crawler

Returns a new instance of Crawler.



9
10
11
12
13
14
15
16
17
# File 'lib/snapcrawl/crawler.rb', line 9

def initialize(url)
  $logger.debug "initializing crawler with %{green}#{url}%{reset}"
  
  config_for_display = Config.settings.dup
  config_for_display['name_template'] = '%%{url}' 

  $logger.debug "config #{config_for_display}"
  @url = url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/snapcrawl/crawler.rb', line 7

def url
  @url
end

Instance Method Details

#crawlObject



19
20
21
22
23
# File 'lib/snapcrawl/crawler.rb', line 19

def crawl
  Dependencies.verify
  todo[url] = Page.new url
  process_todo while todo.any?
end