Class: DoubleCheck::Sitemap
- Inherits:
-
Object
- Object
- DoubleCheck::Sitemap
- Defined in:
- lib/sitemap.rb
Direct Known Subclasses
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(url) ⇒ Sitemap
constructor
A new instance of Sitemap.
- #process ⇒ Object
- #record_result(url, response) ⇒ Object
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
#data ⇒ Object
26 27 28 |
# File 'lib/sitemap.rb', line 26 def data return @data end |
#process ⇒ Object
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 |