Class: Datacite::Mapping::Identifier
- Inherits:
-
Object
- Object
- Datacite::Mapping::Identifier
- Includes:
- XML::Mapping
- Defined in:
- lib/datacite/mapping/identifier.rb
Overview
The persistent identifier that identifies the resource.
Instance Attribute Summary collapse
-
#identifier_type ⇒ String
The identifier type (always 'DOI').
-
#value ⇒ String
The identifier value.
Instance Method Summary collapse
-
#initialize(value:) ⇒ Identifier
constructor
Initializes a new Identifier.
Constructor Details
#initialize(value:) ⇒ Identifier
Initializes a new Datacite::Mapping::Identifier
20 21 22 23 |
# File 'lib/datacite/mapping/identifier.rb', line 20 def initialize(value:) self.identifier_type = 'DOI' self.value = value end |
Instance Attribute Details
#identifier_type ⇒ String
Returns the identifier type (always 'DOI').
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/datacite/mapping/identifier.rb', line 11 class Identifier include XML::Mapping text_node :identifier_type, '@identifierType' text_node :value, 'text()' # Initializes a new {Identifier} # @param value [String] # the identifier value. Must be a valid DOI value (`10.`_registrant code_`/`_suffix_) def initialize(value:) self.identifier_type = 'DOI' self.value = value end alias_method :_value=, :value= private :_value= alias_method :_identifier_type=, :identifier_type= private :_identifier_type= def value=(v) fail ArgumentError, "Identifier value '#{v}' is not a valid DOI" unless v.match(%r{10\..+/.+}) self._value = v end # Sets the identifier type. Should only be called by the XML mapping engine. # @param v [String] # the identifier type (always 'DOI') def identifier_type=(v) fail ArgumentError, "Identifier type '#{v}' must be 'DOI'" unless 'DOI' == v self._identifier_type = v end end |
#value ⇒ String
Returns the identifier value. Must be a valid DOI value (10._registrant code_/_suffix_).
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/datacite/mapping/identifier.rb', line 11 class Identifier include XML::Mapping text_node :identifier_type, '@identifierType' text_node :value, 'text()' # Initializes a new {Identifier} # @param value [String] # the identifier value. Must be a valid DOI value (`10.`_registrant code_`/`_suffix_) def initialize(value:) self.identifier_type = 'DOI' self.value = value end alias_method :_value=, :value= private :_value= alias_method :_identifier_type=, :identifier_type= private :_identifier_type= def value=(v) fail ArgumentError, "Identifier value '#{v}' is not a valid DOI" unless v.match(%r{10\..+/.+}) self._value = v end # Sets the identifier type. Should only be called by the XML mapping engine. # @param v [String] # the identifier type (always 'DOI') def identifier_type=(v) fail ArgumentError, "Identifier type '#{v}' must be 'DOI'" unless 'DOI' == v self._identifier_type = v end end |