Class: SiteMaps::Builder::SitemapIndex::Item

Inherits:
Struct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/site_maps/builder/sitemap_index/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lastmodObject

Returns the value of attribute lastmod

Returns:

  • (Object)

    the current value of lastmod



3
4
5
# File 'lib/site_maps/builder/sitemap_index/item.rb', line 3

def lastmod
  @lastmod
end

#locObject

Returns the value of attribute loc

Returns:

  • (Object)

    the current value of loc



3
4
5
# File 'lib/site_maps/builder/sitemap_index/item.rb', line 3

def loc
  @loc
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


15
16
17
# File 'lib/site_maps/builder/sitemap_index/item.rb', line 15

def eql?(other)
  loc == other.loc
end

#hashObject



20
21
22
# File 'lib/site_maps/builder/sitemap_index/item.rb', line 20

def hash
  loc.hash
end

#relative_directoryObject



24
25
26
27
28
29
30
# File 'lib/site_maps/builder/sitemap_index/item.rb', line 24

def relative_directory
  return unless loc =~ %r{^https?://[^/]+(/.*)$}

  val = File.dirname(Regexp.last_match(1))
  val = val[1..] if val.start_with?("/")
  val
end

#to_xmlObject



6
7
8
9
10
11
12
13
# File 'lib/site_maps/builder/sitemap_index/item.rb', line 6

def to_xml
  builder = ::Builder::XmlMarkup.new
  builder.sitemap do
    builder.loc(loc)
    builder.lastmod w3c_date(lastmod) if lastmod
  end
  builder << "\n"
end