class Datacite::Mapping::Creator

The main researchers involved working on the data, or the authors of the publication in priority order.

Public Class Methods

new(name:, given_name: nil, family_name: nil, identifier: nil, affiliations: []) click to toggle source

Initializes a new {Creator}. @param name [String] The personal name of the creator, in the format ‘Family, Given`. Cannot be empty or nil. @param given_name [String, nil] The given name of the creator. Optional. @param given_name [String, nil] The family name of the creator. Optional. @param identifier [NameIdentifier, nil] An identifier for the creator. Optional. @param affiliations [Array<Affiliation>, nil] The creator’s affiliations. Defaults to an empty list.

# File lib/datacite/mapping/creator.rb, line 22
def initialize(name:, given_name: nil, family_name: nil, identifier: nil, affiliations: [])
  self.name = name
  self.given_name = given_name
  self.family_name = family_name
  self.identifier = identifier
  self.affiliations = affiliations
end

Public Instance Methods

affiliation_names() click to toggle source
# File lib/datacite/mapping/creator.rb, line 75
def affiliation_names
  @affiliations.map { |affil| affil&.value }
end
affiliations=(value) click to toggle source

Affiliations can be entered as an array of Strings or an array of Affiliation objects, but will be stored internally as an array of Affiliation objects

# File lib/datacite/mapping/creator.rb, line 64
def affiliations=(value)
  @affiliations = []
  value&.each do |affil|
    @affiliations << if affil.is_a?(Affiliation)
                       affil
                     else
                       Affiliation.new(value: affil)
                     end
  end
end
creator_name=(value) click to toggle source
# File lib/datacite/mapping/creator.rb, line 42
def creator_name=(value)
  raise ArgumentError, 'CreatorName cannot be empty or nil' unless value

  @creator_name = value
end
family_name=(value) click to toggle source
# File lib/datacite/mapping/creator.rb, line 57
def family_name=(value)
  new_value = value&.strip
  @family_name = new_value
end
given_name=(value) click to toggle source
# File lib/datacite/mapping/creator.rb, line 52
def given_name=(value)
  new_value = value&.strip
  @given_name = new_value
end
name() click to toggle source
# File lib/datacite/mapping/creator.rb, line 48
def name
  @creator_name&.value
end
name=(value) click to toggle source

name can be entered as a string or a CreatorName object, but it will be stored internally as a CreatorName object

# File lib/datacite/mapping/creator.rb, line 32
def name=(value)
  raise ArgumentError, 'Name cannot be empty or nil' unless value

  @creator_name = if value.is_a?(CreatorName)
                    value
                  else
                    CreatorName.new(value: value)
                  end
end