Class: CocinaDisplay::Forms::ResourceType

Inherits:
Form
  • Object
show all
Defined in:
lib/cocina_display/forms/resource_type.rb

Overview

A Resource Type form associated with part or all of a Cocina object.

Instance Attribute Summary

Attributes inherited from Form

#cocina

Instance Method Summary collapse

Methods inherited from Form

from_cocina, #initialize, #label, #type, #values

Constructor Details

This class inherits a constructor from CocinaDisplay::Forms::Form

Instance Method Details

#flat_valueString

For self-deposit resource types, the flat value comprises primary and any subtypes.

Returns:

  • (String)


13
14
15
16
17
18
# File 'lib/cocina_display/forms/resource_type.rb', line 13

def flat_value
  return super unless stanford_self_deposit?
  return primary_type unless subtypes.any?

  "#{primary_type} (#{subtypes.join(", ")})"
end

#mods?Boolean

Is this a MODS resource type?

Returns:

  • (Boolean)


29
30
31
# File 'lib/cocina_display/forms/resource_type.rb', line 29

def mods?
  source == "MODS resource types"
end

#stanford_self_deposit?Boolean

Note:

These are handled separately when displayed.

Is this a Stanford self-deposit resource type?

Returns:

  • (Boolean)


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

def stanford_self_deposit?
  source == "Stanford self-deposit resource types"
end

#to_sString

Resource types are lowercased for display, except self-deposit types.

Returns:

  • (String)


7
8
9
# File 'lib/cocina_display/forms/resource_type.rb', line 7

def to_s
  stanford_self_deposit? ? flat_value : flat_value.downcase
end