Class: DoubleCheck::Sitemap

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

Direct Known Subclasses

CommandLine

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Sitemap

Returns a new instance of Sitemap.



5
6
7
8
# File 'lib/sitemap.rb', line 5

def initialize(url)
  @sitemap_url = url 
  @data = {}
end

Instance Method Details

#dataObject



26
27
28
# File 'lib/sitemap.rb', line 26

def data
  return @data
end

#processObject



10
11
12
13
14
15
16
# File 'lib/sitemap.rb', line 10

def process
  doc = Nokogiri::XML(open(@sitemap_url))
  doc.css('loc').each do |url|
    response = DoubleCheck::CheckUrl.get_response(url.content)
    record_result(url.content, response)
  end
end

#record_result(url, response) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/sitemap.rb', line 18

def record_result(url, response)
  if @data[response.code].nil?
    @data[response.code] = [url]
  else
    @data[response.code].push(url)
  end 
end