Sha256: da2008d9b775d4e23362f52eee0f13a1d97a86b40817380f260687cda5c8ebc7

Contents?: true

Size: 1.59 KB

Versions: 9

Compression:

Stored size: 1.59 KB

Contents

require 'xml/mapping'
require 'datacite/mapping/name_identifier'

module Datacite
  module Mapping
    # The main researchers involved working on the data, or the authors of the publication in priority order.
    class Creator
      include XML::Mapping

      # Initializes a new {Creator}.
      # @param name [String] The personal name of the creator, in the format `Family, Given`. Cannot be empty or nil.
      # @param identifier [NameIdentifier, nil] An identifier for the creator. Optional.
      # @param affiliations [Array<String>, nil] The creator's affiliations. Defaults to an empty list.
      def initialize(name:, identifier: nil, affiliations: [])
        self.name = name
        self.identifier = identifier
        self.affiliations = affiliations
      end

      def name=(value)
        fail ArgumentError, 'Name cannot be empty or nil' unless value && !value.empty?
        @name = value
      end

      def affiliations=(value)
        @affiliations = value || []
      end

      # @!attribute [rw] name
      #   @return [String] The personal name of the creator, in the format `Family, Given`. Cannot be empty or nil.
      text_node :name, 'creatorName'

      # @!attribute [rw] identifier
      #   @return [NameIdentifier, nil] An identifier for the creator. Optional.
      object_node :identifier, 'nameIdentifier', class: NameIdentifier, default_value: nil

      # @!attribute [rw] affiliations
      #   @return [Array<String>, nil] The creator's affiliations. Defaults to an empty list.
      array_node :affiliations, 'affiliation', class: String, default_value: []

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
datacite-mapping-0.1.17.2 lib/datacite/mapping/creator.rb
datacite-mapping-0.1.17.1 lib/datacite/mapping/creator.rb
datacite-mapping-0.1.17 lib/datacite/mapping/creator.rb
datacite-mapping-0.1.16 lib/datacite/mapping/creator.rb
datacite-mapping-0.1.15 lib/datacite/mapping/creator.rb
datacite-mapping-0.1.14 lib/datacite/mapping/creator.rb
datacite-mapping-0.1.13 lib/datacite/mapping/creator.rb
datacite-mapping-0.1.12 lib/datacite/mapping/creator.rb
datacite-mapping-0.1.10 lib/datacite/mapping/creator.rb