Class: Arwen::Url
- Inherits:
-
Object
- Object
- Arwen::Url
- Defined in:
- lib/arwen/url.rb
Overview
Models the sitemap <url> schema definition according the sitemap.org protocol
Instance Attribute Summary collapse
-
#changefreq ⇒ string
<changefreq> schema value.
-
#lastmod ⇒ string
<lastmod> schema value.
-
#priority ⇒ float
<priority> schema value.
-
#raw ⇒ Ox::Element
readonly
The Ox::Element object used to initialize the Url instance.
-
#url ⇒ string
<loc> schema value.
Instance Method Summary collapse
-
#initialize(ox_element) ⇒ Url
constructor
Create a new SitemapParser::URL.
-
#to_date ⇒ Date
converts the string lastmod value to a ‘Date` object.
Constructor Details
#initialize(ox_element) ⇒ Url
Create a new SitemapParser::URL
28 29 30 31 32 33 34 |
# File 'lib/arwen/url.rb', line 28 def initialize(ox_element) @url = ox_element.locate("loc/*").first @lastmod = ox_element.locate("lastmod/*").first @priority = ox_element.locate("priority/*").first&.to_f @changefreq = ox_element.locate("changefreq/*").first @raw = ox_element end |
Instance Attribute Details
#changefreq ⇒ string
Returns <changefreq> schema value.
18 19 20 |
# File 'lib/arwen/url.rb', line 18 def changefreq @changefreq end |
#lastmod ⇒ string
Returns <lastmod> schema value.
12 13 14 |
# File 'lib/arwen/url.rb', line 12 def lastmod @lastmod end |
#priority ⇒ float
Returns <priority> schema value.
15 16 17 |
# File 'lib/arwen/url.rb', line 15 def priority @priority end |
#raw ⇒ Ox::Element (readonly)
The Ox::Element object used to initialize the Url instance
22 23 24 |
# File 'lib/arwen/url.rb', line 22 def raw @raw end |
#url ⇒ string
Returns <loc> schema value.
9 10 11 |
# File 'lib/arwen/url.rb', line 9 def url @url end |
Instance Method Details
#to_date ⇒ Date
converts the string lastmod value to a ‘Date` object
39 40 41 42 43 |
# File 'lib/arwen/url.rb', line 39 def to_date return nil if lastmod.nil? Date.parse(lastmod) end |