Class: CocinaDisplay::RelatedResource

Overview

Note:

Related resources have no structural metadata.

A resource related to the record. See github.com/sul-dlss/cocina-models/blob/main/lib/cocina/models/related_resource.rb

Instance Attribute Summary collapse

Attributes inherited from JsonBackedRecord

#cocina_doc

Instance Method Summary collapse

Methods included from Concerns::Geospatial

#coordinates, #coordinates_as_envelope, #coordinates_as_point, #coordinates_as_wkt, #geonames_ids

Methods included from Concerns::Languages

#language_display_data, #languages, #searchworks_language_names

Methods included from Concerns::Forms

#archived_website?, #cartographic?, #dataset?, #extents, #form_display_data, #form_note_display_data, #forms, #genre_display_data, #genres, #genres_search, #map_display_data, #mods_resource_types, #periodical?, #searchworks_resource_types

Methods included from Concerns::Subjects

#subject_all, #subject_all_display, #subject_display_data, #subject_genres, #subject_names, #subject_occupations, #subject_other, #subject_places, #subject_temporal, #subject_temporal_genre, #subject_titles, #subject_topics, #subject_topics_other

Methods included from Concerns::UrlHelpers

#download_url, #iiif_manifest_url, #oembed_url, #purl_url

Methods included from Concerns::Titles

#additional_titles, #all_titles, #display_title, #full_title, #main_title, #primary_title, #secondary_titles, #sort_title, #title_display_data

Methods included from Concerns::Notes

#abstract_display_data, #general_note_display_data, #notes, #preferred_citation_display_data, #table_of_contents_display_data

Methods included from Concerns::Identifiers

#bare_druid, #doi, #doi_url, #druid, #folio_hrid, #identifier_display_data, #identifiers, #searchworks_id

Methods included from Concerns::Contributors

#additional_contributor_names, #additional_contributors, #conference_contributor_names, #contributor_display_data, #contributor_names_by_role, #contributors, #contributors_by_role, #impersonal_contributor_names, #main_contributor, #main_contributor_name, #organization_contributor_names, #person_contributor_names, #publisher_contributors, #publisher_names, #sort_contributor_name

Methods included from Concerns::Events

#admin_creation_event, #earliest_preferred_date, #event_date_display_data, #event_dates, #event_note_display_data, #events, #imprint_events, #imprint_str, #pub_date, #pub_date_edtf, #pub_year_int, #pub_year_int_range, #pub_year_str, #publication_events, #publication_places

Methods included from Concerns::Accesses

#access_contacts, #access_display_data, #accesses, #contact_email_display_data, #copyright_display_data, #license_display_data, #urls, #use_and_reproduction_display_data

Methods inherited from JsonBackedRecord

#path

Constructor Details

#initialize(cocina_doc) ⇒ RelatedResource

Restructure the hash so that everything is under “description” key, since it’s all descriptive metadata. This makes most CocinaRecord methods work.



27
28
29
30
# File 'lib/cocina_display/related_resource.rb', line 27

def initialize(cocina_doc)
  @type = cocina_doc["type"]
  super({"description" => cocina_doc.except("type")})
end

Instance Attribute Details

#typeString (readonly)

Description of the relation to the source record.



23
24
25
# File 'lib/cocina_display/related_resource.rb', line 23

def type
  @type
end

Instance Method Details

#display_dataArray<DisplayData>

Note:

Used for extended display of citations, e.g. on hp566jq8781.

Nested display data for the related resource. Combines titles, contributors, notes, and access information.

Returns:



61
62
63
# File 'lib/cocina_display/related_resource.rb', line 61

def display_data
  title_display_data + contributor_display_data + general_note_display_data + preferred_citation_display_data + access_display_data
end

#labelString

Label used to group the related resource for display.

Returns:

  • (String)


34
35
36
# File 'lib/cocina_display/related_resource.rb', line 34

def label
  cocina_doc.dig("description", "displayLabel").presence || type_label
end

#to_sString?

String representation of the related resource.

Returns:

  • (String, nil)


40
41
42
# File 'lib/cocina_display/related_resource.rb', line 40

def to_s
  main_title || url
end

#urlString?

URL to the related resource for link construction. If there are multiple URLs, uses the first.

Returns:

  • (String, nil)


47
48
49
# File 'lib/cocina_display/related_resource.rb', line 47

def url
  urls.first&.to_s || purl_url
end

#url?Boolean

Is this a related resource with a URL?

Returns:

  • (Boolean)


53
54
55
# File 'lib/cocina_display/related_resource.rb', line 53

def url?
  url.present?
end