Sha256: 78b04b94f2dffc1e711fa38837f62c25eaf959c4ea3467832bd8284f6b008b75

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

require 'xml/mapping_extensions'

module Datacite
  module Mapping

    # An identifier or identifiers other than the primary {Identifier}
    # applied to the {Resource}.
    class AlternateIdentifier
      include XML::Mapping

      root_element_name 'alternateIdentifier'

      text_node :type, '@alternateIdentifierType'
      text_node :value, 'text()'

      alias_method :_type=, :type=
      private :_type=
      alias_method :_value=, :value=
      private :_value=

      # Initializes a new {AlternateIdentifier}
      # @param type [String] the identifier type
      # @param value [String] the identifier value
      def initialize(type:, value:)
        self.type = type
        self.value = value
      end

      # Sets the type. Cannot be nil.
      # @param val [String] the identifier type
      def type=(val)
        fail ArgumentError, 'No identifier type provided' unless val
        self._type = val
      end

      # Sets the value. Cannot be nil.
      # @param val [String] the value
      def value=(val)
        fail ArgumentError, 'No identifier value provided' unless val
        self._value = val
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
datacite-mapping-0.1.5 lib/datacite/mapping/alternate_identifier.rb
datacite-mapping-0.1.4 lib/datacite/mapping/alternate_identifier.rb
datacite-mapping-0.1.3 lib/datacite/mapping/alternate_identifier.rb
datacite-mapping-0.1.2 lib/datacite/mapping/alternate_identifier.rb
datacite-mapping-0.1.1 lib/datacite/mapping/alternate_identifier.rb
datacite-mapping-0.1.0 lib/datacite/mapping/alternate_identifier.rb