Class: ModsDisplay::Collection

Inherits:
Field
  • Object
show all
Defined in:
lib/mods_display/fields/collection.rb

Overview

Collection class to parse collection data out of Mods relatedItem fields

Instance Method Summary collapse

Methods inherited from Field

#initialize, #label, #render_in, #to_html

Constructor Details

This class inherits a constructor from ModsDisplay::Field

Instance Method Details

#collection_label(value) ⇒ Object



8
9
10
# File 'lib/mods_display/fields/collection.rb', line 8

def collection_label(value)
  displayLabel(value) || I18n.t('mods_display.collection')
end

#fieldsObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mods_display/fields/collection.rb', line 12

def fields
  return_fields = []
  @values.each do |value|
    next unless related_item_is_a_collection?(value)

    return_fields << ModsDisplay::Values.new(
      label: collection_label(value),
      values: [element_text(value.titleInfo)]
    )
  end
  collapse_fields(return_fields)
end