Class: Datacite::Mapping::Creator

Inherits:
Object
  • Object
show all
Includes:
XML::Mapping
Defined in:
lib/datacite/mapping/creator.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, given_name: nil, family_name: nil, identifier: nil, affiliations: []) ⇒ Creator

Initializes a new Datacite::Mapping::Creator.

Parameters:

  • name (String)

    The personal name of the creator, in the format Family, Given. Cannot be empty or nil.

  • given_name (String, nil) (defaults to: nil)

    The given name of the creator. Optional.

  • given_name (String, nil) (defaults to: nil)

    The family name of the creator. Optional.

  • identifier (NameIdentifier, nil) (defaults to: nil)

    An identifier for the creator. Optional.

  • affiliations (Array<Affiliation>, nil) (defaults to: [])

    The creator's affiliations. Defaults to an empty list.



22
23
24
25
26
27
28
# 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

Instance Attribute Details

#affiliationsArray<String>?

Returns The creator's affiliations. Defaults to an empty list.

Returns:

  • (Array<String>, nil)

    The creator's affiliations. Defaults to an empty list.



97
# File 'lib/datacite/mapping/creator.rb', line 97

array_node :affiliations, 'affiliation', class: Affiliation, default_value: []

#family_nameString?

Returns The family name of the creator. Optional.

Returns:

  • (String, nil)

    The family name of the creator. Optional.



89
# File 'lib/datacite/mapping/creator.rb', line 89

text_node :family_name, 'familyName', default_value: nil

#given_nameString?

Returns The given name of the creator. Optional.

Returns:

  • (String, nil)

    The given name of the creator. Optional.



85
# File 'lib/datacite/mapping/creator.rb', line 85

text_node :given_name, 'givenName', default_value: nil

#identifierNameIdentifier?

Returns An identifier for the creator. Optional.

Returns:



93
# File 'lib/datacite/mapping/creator.rb', line 93

object_node :identifier, 'nameIdentifier', class: NameIdentifier, default_value: nil

#nameString

Returns The personal name of the creator, in the format Family, Given. Cannot be empty or nil.

Returns:

  • (String)

    The personal name of the creator, in the format Family, Given. Cannot be empty or nil.



81
82
83
# File 'lib/datacite/mapping/creator.rb', line 81

def name
  @creator_name&.value
end

Instance Method Details

#affiliation_names



75
76
77
# File 'lib/datacite/mapping/creator.rb', line 75

def affiliation_names
  @affiliations.map { |affil| affil&.value }
end

#creator_name=(value)

Raises:

  • (ArgumentError)


42
43
44
45
46
# 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