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(related_item_element) ⇒ Object



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

def collection_label(related_item_element)
  displayLabel(related_item_element) || 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 = []
  @stanford_mods_elements.each do |related_item_element|
    next unless related_item_is_a_collection?(related_item_element)

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