Class: ModsDisplay::Location

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

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

#fieldsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mods_display/fields/location.rb', line 5

def fields
  return_fields = []
  @stanford_mods_elements.each do |location_element|
    location_element.children.each do |child|
      next unless location_field_keys.include?(child.name.to_sym)

      if child.name.to_sym == :url
        loc_label = displayLabel(location_element) || I18n.t('mods_display.location')
        value = "<a href='#{element_text(child)}'>#{(displayLabel(child) || element_text(child)).gsub(/:$/,
                                                                                                      '')}</a>"
      else
        loc_label = location_label(child) || displayLabel(location_element) || I18n.t('mods_display.location')
        value = element_text(child)
      end
      return_fields << ModsDisplay::Values.new(
        label: loc_label || displayLabel(location_element) || I18n.t('mods_display.location'),
        values: [value]
      )
    end
  end
  collapse_fields(return_fields)
end