Class: CocinaDisplay::Contributors::Affiliation

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina_display/contributors/affiliation.rb

Overview

An affiliation associated with a contributor.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cocina) ⇒ Affiliation

Initialize an Affiliation from Cocina structured data.

Parameters:

  • cocina (Hash)


11
12
13
# File 'lib/cocina_display/contributors/affiliation.rb', line 11

def initialize(cocina)
  @cocina = cocina
end

Instance Attribute Details

#cocinaObject (readonly)

Returns the value of attribute cocina.



7
8
9
# File 'lib/cocina_display/contributors/affiliation.rb', line 7

def cocina
  @cocina
end

Instance Method Details

#display_nameString?

The name of the institution or organization.

Examples:

“Stanford University, Department of Special Collections”

Returns:

  • (String, nil)


24
25
26
# File 'lib/cocina_display/contributors/affiliation.rb', line 24

def display_name
  name_components.join(", ") if name_components.any?
end

#identifiersArray<CocinaDisplay::Identifier>

Identifiers associated with the Affiliation.

Returns:



50
51
52
53
# File 'lib/cocina_display/contributors/affiliation.rb', line 50

def identifiers
  @identifiers ||= Utils.flatten_nested_values(cocina)
    .pluck("identifier").flatten.compact_blank.map { |id| CocinaDisplay::Identifier.new(id) }
end

#name_componentsArray<String>

All components of the Affiliation name as an array of strings.

Examples:

“Stanford University”, “Department of Special Collections”

Returns:

  • (Array<String>)


58
59
60
# File 'lib/cocina_display/contributors/affiliation.rb', line 58

def name_components
  @name_components ||= Utils.flatten_nested_values(cocina).pluck("value").compact_blank
end

#rorString?

ROR URI for the Affiliation, if present.

Examples:

Returns:

  • (String, nil)


37
38
39
# File 'lib/cocina_display/contributors/affiliation.rb', line 37

def ror
  ror_identifier&.uri
end

#ror?Boolean

Does this Affiliation have a ROR ID?

Returns:

  • (Boolean)


30
31
32
# File 'lib/cocina_display/contributors/affiliation.rb', line 30

def ror?
  ror_identifier.present?
end

#ror_idString?

ROR ID for the Affiliation, if present.

Examples:

00f54p054

Returns:

  • (String, nil)


44
45
46
# File 'lib/cocina_display/contributors/affiliation.rb', line 44

def ror_id
  ror_identifier&.identifier
end

#ror_identifierCocinaDisplay::Identifier?

Note:

This will usually be the most general ROR ID, if multiple.

The first Identifier object that contains a ROR ID.

Returns:



65
66
67
# File 'lib/cocina_display/contributors/affiliation.rb', line 65

def ror_identifier
  identifiers.find { |id| id.type == "ROR" }
end

#to_sString?

String representation of the affiliation, using display name.

Returns:

  • (String, nil)


17
18
19
# File 'lib/cocina_display/contributors/affiliation.rb', line 17

def to_s
  display_name
end