Class: Arwen::Url

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

Overview

Models the sitemap <url> schema definition according the sitemap.org protocol

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ox_element) ⇒ Url

Create a new SitemapParser::URL

Parameters:

  • ox_element (Ox::Element)

    element in the sitemap tree

See Also:



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

#changefreqstring

Returns <changefreq> schema value.

Returns:

  • (string)

    <changefreq> schema value



18
19
20
# File 'lib/arwen/url.rb', line 18

def changefreq
  @changefreq
end

#lastmodstring

Returns <lastmod> schema value.

Returns:

  • (string)

    <lastmod> schema value



12
13
14
# File 'lib/arwen/url.rb', line 12

def lastmod
  @lastmod
end

#priorityfloat

Returns <priority> schema value.

Returns:

  • (float)

    <priority> schema value



15
16
17
# File 'lib/arwen/url.rb', line 15

def priority
  @priority
end

#rawOx::Element (readonly)

The Ox::Element object used to initialize the Url instance

Returns:

  • (Ox::Element)


22
23
24
# File 'lib/arwen/url.rb', line 22

def raw
  @raw
end

#urlstring

Returns <loc> schema value.

Returns:

  • (string)

    <loc> schema value



9
10
11
# File 'lib/arwen/url.rb', line 9

def url
  @url
end

Instance Method Details

#to_dateDate

converts the string lastmod value to a ‘Date` object

Returns:

  • (Date)


39
40
41
42
43
# File 'lib/arwen/url.rb', line 39

def to_date
  return nil if lastmod.nil?

  Date.parse(lastmod)
end