Class: ModsDisplay::Name
- Includes:
- RelatorCodes
- Defined in:
- lib/mods_display/fields/name.rb
Defined Under Namespace
Classes: Person
Instance Method Summary collapse
Methods included from RelatorCodes
Methods inherited from Field
Constructor Details
This class inherits a constructor from ModsDisplay::Field
Instance Method Details
#fields ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mods_display/fields/name.rb', line 4 def fields return_fields = @values.map do |value| person = if value.displayForm.length > 0 ModsDisplay::Name::Person.new(name: value.displayForm.text) elsif !name_parts(value).empty? ModsDisplay::Name::Person.new(name: name_parts(value)) end # The person may have multiple roles, so we have to divide them up into an array role_labels(value).collect do |role_label| ModsDisplay::Values.new(label: displayLabel(value) || role_label, values: [person]) if person end end.flatten.compact collapse_roles(collapse_fields(return_fields)) end |
#to_html ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mods_display/fields/name.rb', line 19 def to_html return nil if fields.empty? || @config.ignore? output = '' fields.each do |field| output << "<dt#{label_class} #{sanitized_field_title(field.label)}>#{field.label}</dt>" output << "<dd#{value_class}>" output << field.values.map do |val| if @config.link link_to_value(val.name) else val.to_s end end.join(@config.delimiter) output << '</dd>' end output end |