Class: Resync::Link
- Inherits:
-
Descriptor
- Object
- Descriptor
- Resync::Link
- Includes:
- XML::Mapping
- Defined in:
- lib/resync/link.rb
Overview
A link to a related resource. See “Linking to Related Resources” under section 5.1, Synchronization Processes: Source Perspective in the ResourceSync specification.
Instance Attribute Summary collapse
-
#priority ⇒ Integer
The priority of the linked resource among links with the same relation type.
-
#rel ⇒ String
The relationship of the linked resource to the original resource.
-
#uri ⇒ URI
The URI of the linked resource.
Attributes inherited from Descriptor
#encoding, #hashes, #length, #mime_type, #modified_time, #path
Instance Method Summary collapse
-
#initialize(rel:, uri:, priority: nil, modified_time: nil, length: nil, mime_type: nil, encoding: nil, hashes: {}, path: nil) ⇒ Link
constructor
A new instance of Link.
Methods inherited from Descriptor
Constructor Details
#initialize(rel:, uri:, priority: nil, modified_time: nil, length: nil, mime_type: nil, encoding: nil, hashes: {}, path: nil) ⇒ Link
Returns a new instance of Link.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/resync/link.rb', line 54 def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists rel:, uri:, priority: nil, modified_time: nil, length: nil, mime_type: nil, encoding: nil, hashes: {}, path: nil ) super(modified_time: modified_time, length: length, mime_type: mime_type, encoding: encoding, hashes: hashes, path: path) self.rel = rel self.uri = uri self.priority = priority end |
Instance Attribute Details
#priority ⇒ Integer
Returns the priority of the linked resource among links with the same relation type. Values should be in the range 1-999,999 (inclusive). Lower values indicate higher priorities.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/resync/link.rb', line 21 class Link < Descriptor include ::XML::Mapping # ------------------------------------------------------------ # Attributes root_element_name 'ln' text_node :rel, '@rel', default_value: nil uri_node :uri, '@href', default_value: nil numeric_node :priority, '@pri', default_value: nil # ------------------------------------------------------------ # Initializer # @param rel [String] the relationship of the linked resource to the # original resource. See {http://tools.ietf.org/html/rfc5988 RFC 5988}, # "Web Linking". for information on link relation types. # @param uri [URI] the URI of the linked resource. # @param priority [Integer] the priority of the linked resource among links # with the same relation type. Values should be in the range # 1-999,999 (inclusive). Lower values indicate higher priorities. # @param modified_time [Time] The date and time when the referenced resource was last modified. # @param length [Integer] The content length of the referenced resource. # @param mime_type [MIME::Type] The media type of the referenced resource. # @param encoding [String] Any content encoding (if any) applied to the data in the # referenced resource (e.g. for compression) # @param hashes [Hash<String, String>] Fixity information for the referenced # resource, as a map from hash algorithm tokens (e.g. +md5+, +sha-256+) # to hex-encoded digest values. # @param path [String] For +ResourceDumpManifests+ and +ChangeDumpManifests+, # the path to the referenced resource within the dump ZIP file. # @raise [URI::InvalidURIError] if +uri+ cannot be converted to a URI. def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists rel:, uri:, priority: nil, modified_time: nil, length: nil, mime_type: nil, encoding: nil, hashes: {}, path: nil ) super(modified_time: modified_time, length: length, mime_type: mime_type, encoding: encoding, hashes: hashes, path: path) self.rel = rel self.uri = uri self.priority = priority end # ------------------------------------------------------------ # Custom setters # Sets the URI of the linked resource. Strings will be converted to +URI+ objects. # @param value [URI, String] the URI. # @raise [URI::InvalidURIError] if +value+ cannot be converted to a URI. def uri=(value) @uri = XML.to_uri(value) end end |
#rel ⇒ String
Returns the relationship of the linked resource to the original resource. See RFC 5988, “Web Linking”. for information on link relation types.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/resync/link.rb', line 21 class Link < Descriptor include ::XML::Mapping # ------------------------------------------------------------ # Attributes root_element_name 'ln' text_node :rel, '@rel', default_value: nil uri_node :uri, '@href', default_value: nil numeric_node :priority, '@pri', default_value: nil # ------------------------------------------------------------ # Initializer # @param rel [String] the relationship of the linked resource to the # original resource. See {http://tools.ietf.org/html/rfc5988 RFC 5988}, # "Web Linking". for information on link relation types. # @param uri [URI] the URI of the linked resource. # @param priority [Integer] the priority of the linked resource among links # with the same relation type. Values should be in the range # 1-999,999 (inclusive). Lower values indicate higher priorities. # @param modified_time [Time] The date and time when the referenced resource was last modified. # @param length [Integer] The content length of the referenced resource. # @param mime_type [MIME::Type] The media type of the referenced resource. # @param encoding [String] Any content encoding (if any) applied to the data in the # referenced resource (e.g. for compression) # @param hashes [Hash<String, String>] Fixity information for the referenced # resource, as a map from hash algorithm tokens (e.g. +md5+, +sha-256+) # to hex-encoded digest values. # @param path [String] For +ResourceDumpManifests+ and +ChangeDumpManifests+, # the path to the referenced resource within the dump ZIP file. # @raise [URI::InvalidURIError] if +uri+ cannot be converted to a URI. def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists rel:, uri:, priority: nil, modified_time: nil, length: nil, mime_type: nil, encoding: nil, hashes: {}, path: nil ) super(modified_time: modified_time, length: length, mime_type: mime_type, encoding: encoding, hashes: hashes, path: path) self.rel = rel self.uri = uri self.priority = priority end # ------------------------------------------------------------ # Custom setters # Sets the URI of the linked resource. Strings will be converted to +URI+ objects. # @param value [URI, String] the URI. # @raise [URI::InvalidURIError] if +value+ cannot be converted to a URI. def uri=(value) @uri = XML.to_uri(value) end end |
#uri ⇒ URI
Returns the URI of the linked resource.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/resync/link.rb', line 21 class Link < Descriptor include ::XML::Mapping # ------------------------------------------------------------ # Attributes root_element_name 'ln' text_node :rel, '@rel', default_value: nil uri_node :uri, '@href', default_value: nil numeric_node :priority, '@pri', default_value: nil # ------------------------------------------------------------ # Initializer # @param rel [String] the relationship of the linked resource to the # original resource. See {http://tools.ietf.org/html/rfc5988 RFC 5988}, # "Web Linking". for information on link relation types. # @param uri [URI] the URI of the linked resource. # @param priority [Integer] the priority of the linked resource among links # with the same relation type. Values should be in the range # 1-999,999 (inclusive). Lower values indicate higher priorities. # @param modified_time [Time] The date and time when the referenced resource was last modified. # @param length [Integer] The content length of the referenced resource. # @param mime_type [MIME::Type] The media type of the referenced resource. # @param encoding [String] Any content encoding (if any) applied to the data in the # referenced resource (e.g. for compression) # @param hashes [Hash<String, String>] Fixity information for the referenced # resource, as a map from hash algorithm tokens (e.g. +md5+, +sha-256+) # to hex-encoded digest values. # @param path [String] For +ResourceDumpManifests+ and +ChangeDumpManifests+, # the path to the referenced resource within the dump ZIP file. # @raise [URI::InvalidURIError] if +uri+ cannot be converted to a URI. def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists rel:, uri:, priority: nil, modified_time: nil, length: nil, mime_type: nil, encoding: nil, hashes: {}, path: nil ) super(modified_time: modified_time, length: length, mime_type: mime_type, encoding: encoding, hashes: hashes, path: path) self.rel = rel self.uri = uri self.priority = priority end # ------------------------------------------------------------ # Custom setters # Sets the URI of the linked resource. Strings will be converted to +URI+ objects. # @param value [URI, String] the URI. # @raise [URI::InvalidURIError] if +value+ cannot be converted to a URI. def uri=(value) @uri = XML.to_uri(value) end end |