Class: Resync::Resource

Inherits:
Augmented show all
Includes:
XML::Mapping
Defined in:
lib/resync/resource.rb

Overview

A resource (i.e., <url> or <sitemap>). See section 7, Sitemap Document Formats, in the ResourceSync specification.

Instance Attribute Summary

Attributes inherited from Augmented

#links, #metadata

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Augmented

#at_time, #change, #completed_time, #from_time, #link_for, #links_for, #until_time

Constructor Details

#initialize(uri:, modified_time: nil, changefreq: nil, priority: nil, links: [], metadata: nil) ⇒ Resource

Returns a new instance of Resource.

Parameters:

  • modified_time (Time) (defaults to: nil)

    The date and time when the referenced resource was last modified.

  • changefreq (ChangeFrequency) (defaults to: nil)

    how frequently the referenced resource is likely to change.

  • priority (Number) (defaults to: nil)

    the priority of this resource relative to other resources from the same provider. Allows robots to decide which resources to crawl or harvest. Values should be in the range 0-1.0 (inclusive), where 0 is the lowest priority and 1.0 is the highest.

  • links (Array<Link>) (defaults to: [])

    related links (i.e. <rs:ln>).

  • metadata (Metadata) (defaults to: nil)

    metadata about this resource.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/resync/resource.rb', line 33

def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
    uri:,
    modified_time: nil,
    changefreq: nil,
    priority: nil,
    links: [],
    metadata: nil
)
  super(links: links)
  self.uri = uri
  self.modified_time = modified_time
  self.changefreq = changefreq
  self.priority = priority
  self. = 
end

Class Method Details

.all_xml_mapping_nodes(options = { mapping: nil, create: true }) ⇒ Object

ResourceSync schema requires ‘##other’ elements to appear last



67
68
69
# File 'lib/resync/resource.rb', line 67

def self.all_xml_mapping_nodes(options = { mapping: nil, create: true })
  xml_mapping_nodes(options) + superclass.all_xml_mapping_nodes(options)
end

Instance Method Details

#capabilityObject


Public methods



59
60
61
# File 'lib/resync/resource.rb', line 59

def capability
   ? .capability : nil
end

#uri=(value) ⇒ Object


Custom setters



52
53
54
# File 'lib/resync/resource.rb', line 52

def uri=(value)
  @uri = XML.to_uri(value)
end