Class: ExtraSpace::Sitemap
- Inherits:
-
Object
- Object
- ExtraSpace::Sitemap
- Defined in:
- lib/extraspace/sitemap.rb
Overview
A sitemap on extraspace.com.
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(links:) ⇒ Sitemap
constructor
A new instance of Sitemap.
- #inspect ⇒ String
Constructor Details
#initialize(links:) ⇒ Sitemap
Returns a new instance of Sitemap.
34 35 36 |
# File 'lib/extraspace/sitemap.rb', line 34 def initialize(links:) @links = links end |
Instance Attribute Details
Class Method Details
.fetch(url:) ⇒ Sitemap
28 29 30 31 |
# File 'lib/extraspace/sitemap.rb', line 28 def self.fetch(url:) document = Crawler.xml(url:) parse(document:) end |
.parse(document:) ⇒ Sitemap
15 16 17 18 19 20 21 22 23 |
# File 'lib/extraspace/sitemap.rb', line 15 def self.parse(document:) links = document.xpath('//xmlns:url').map do |url| loc = url.at_xpath('xmlns:loc')&.text lastmod = url.at_xpath('xmlns:lastmod')&.text Link.new(loc:, lastmod:) end new(links: links) end |
Instance Method Details
#inspect ⇒ String
39 40 41 |
# File 'lib/extraspace/sitemap.rb', line 39 def inspect "#<#{self.class.name} links=#{@links.inspect}>" end |