Class: CocinaDisplay::Subjects::NameSubjectValue

Inherits:
SubjectValue
  • Object
show all
Defined in:
lib/cocina_display/subjects/subject_value.rb

Overview

A subject value representing a named entity.

Instance Attribute Summary collapse

Attributes inherited from SubjectValue

#cocina, #type

Instance Method Summary collapse

Methods inherited from SubjectValue

atomic_types, from_cocina, split_pre_coordinated_values

Constructor Details

#initialize(cocina) ⇒ NameSubjectValue

Initialize a NameSubjectValue object with Cocina structured data.

Parameters:

  • cocina (Hash)

    The Cocina structured data for the subject.



63
64
65
66
# File 'lib/cocina_display/subjects/subject_value.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_value.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_value.rb', line 71

def to_s
  name.to_s(with_date: true)
end