Class: CocinaDisplay::Subjects::NameSubjectPart

Inherits:
SubjectPart
  • Object
show all
Defined in:
lib/cocina_display/subjects/subject_part.rb

Overview

A subject part representing a named entity.

Instance Attribute Summary collapse

Attributes inherited from SubjectPart

#cocina, #type

Instance Method Summary collapse

Methods inherited from SubjectPart

atomic_types, from_cocina, split_pre_coordinated_values

Constructor Details

#initialize(cocina) ⇒ NameSubjectPart

Initialize a NameSubjectPart object with Cocina structured data.

Parameters:

  • cocina (Hash)

    The Cocina structured data for the subject part.



63
64
65
66
# File 'lib/cocina_display/subjects/subject_part.rb', line 63

def initialize(cocina)
  super
  @name = Contributors::Name.new(cocina)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



59
60
61
# File 'lib/cocina_display/subjects/subject_part.rb', line 59

def name
  @name
end

Instance Method Details

#to_sString

Use the contributor name formatting rules for display.

Returns:

  • (String)

    The formatted name string, including life dates

See Also:

  • Contributor::Name#to_s


71
72
73
# File 'lib/cocina_display/subjects/subject_part.rb', line 71

def to_s
  name.to_s(with_date: true)
end