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, #to_html

Constructor Details

This class inherits a constructor from ModsDisplay::Field

Instance Method Details

#collection_label(value) ⇒ Object



6
7
8
# File 'lib/mods_display/fields/collection.rb', line 6

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

#fieldsObject



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

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: [value.titleInfo.text.strip]
    )
  end
  collapse_fields(return_fields)
end