Class: Datacite::Mapping::Contributor

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

Overview

The institution or person responsible for collecting, creating, or otherwise contributing to the developement of the dataset.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, identifier: nil, affiliations: nil, type:) ⇒ Contributor

Initializes a new Datacite::Mapping::Contributor.

Parameters:

  • name (String)

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

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

    an identifier for the contributor. Optional.

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

    the contributor's affiliations. Defaults to an empty list.

  • type (ContributorType)

    the contributor type. Cannot be nil.



90
91
92
93
94
95
# File 'lib/datacite/mapping/contributor.rb', line 90

def initialize(name:, identifier: nil, affiliations: nil, type:)
  self.name = name
  self.identifier = identifier
  self.affiliations = affiliations || []
  self.type = type
end

Instance Attribute Details

#affiliationsArray<String>

Returns the contributor's affiliations. Defaults to an empty list.

Returns:

  • (Array<String>)

    the contributor's affiliations. Defaults to an empty list.



143
# File 'lib/datacite/mapping/contributor.rb', line 143

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.



135
# File 'lib/datacite/mapping/contributor.rb', line 135

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.



131
# File 'lib/datacite/mapping/contributor.rb', line 131

text_node :given_name, 'givenName', default_value: nil

#identifierNameIdentifier?

Returns an identifier for the contributor. Optional.

Returns:

  • (NameIdentifier, nil)

    an identifier for the contributor. Optional.



139
# File 'lib/datacite/mapping/contributor.rb', line 139

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.



127
128
129
# File 'lib/datacite/mapping/contributor.rb', line 127

def name
  @contributor_name&.value
end

#typeContributorType

Returns the contributor type. Cannot be nil.

Returns:



147
# File 'lib/datacite/mapping/contributor.rb', line 147

typesafe_enum_node :type, '@contributorType', class: ContributorType

Instance Method Details

#contributor_name=(value)

Raises:

  • (ArgumentError)


109
110
111
112
113
# File 'lib/datacite/mapping/contributor.rb', line 109

def contributor_name=(value)
  raise ArgumentError, 'ContributorName cannot be empty or nil' unless value

  @contributor_name = value
end