Module: Stanford::Mods::Name

Included in:
Record
Defined in:
lib/stanford-mods/concerns/name.rb

Instance Method Summary collapse

Instance Method Details

#sw_addl_authorsArray<String>

all names, in display form, except the main_author

names will be the display_value_w_date form
see Mods::Record.name  in nom_terminology for details on the display_value algorithm

Returns:

  • (Array<String>)

    values for author_7xx_search field



22
23
24
# File 'lib/stanford-mods/concerns/name.rb', line 22

def sw_addl_authors
  mods_ng_xml.plain_name.map(&:display_value_w_date) - [sw_main_author]
end

#sw_corporate_authorsArray<String>

Returns values for author_corp_display.

Returns:

  • (Array<String>)

    values for author_corp_display



38
39
40
# File 'lib/stanford-mods/concerns/name.rb', line 38

def sw_corporate_authors
  mods_ng_xml.corporate_name.map(&:display_value_w_date)
end

#sw_impersonal_authorsArray<String>

return the display_value_w_date for all <mods><name> elements that do not have type=‘personal’

Returns:

  • (Array<String>)

    values for author_other_facet



33
34
35
# File 'lib/stanford-mods/concerns/name.rb', line 33

def sw_impersonal_authors
  mods_ng_xml.plain_name.select { |n| n.type_at != 'personal' }.map(&:display_value_w_date)
end

#sw_main_authorString

the first encountered <mods><name> element with marcrelator flavor role of ‘Creator’ or ‘Author’. if no marcrelator ‘Creator’ or ‘Author’, the first name without a role. if no name without a role, then nil

Returns:

  • (String)

    value for author_1xx_search field



11
12
13
14
15
16
# File 'lib/stanford-mods/concerns/name.rb', line 11

def sw_main_author
  result = mods_ng_xml.plain_name.find { |n| n.role.any? { |r| r.authority.include?('marcrelator') && r.value.any? { |v| v.match(/creator/i) || v.match?(/author/i) } } }
  result ||= mods_ng_xml.plain_name.find { |n| n.role.empty? }

  result&.display_value_w_date
end

#sw_meeting_authorsArray<String>

Returns values for author_meeting_display.

Returns:

  • (Array<String>)

    values for author_meeting_display



43
44
45
# File 'lib/stanford-mods/concerns/name.rb', line 43

def sw_meeting_authors
  mods_ng_xml.conference_name.map(&:display_value_w_date)
end

#sw_person_authorsArray<String>

Returns values for author_person_facet, author_person_display.

Returns:

  • (Array<String>)

    values for author_person_facet, author_person_display



27
28
29
# File 'lib/stanford-mods/concerns/name.rb', line 27

def sw_person_authors
  mods_ng_xml.personal_name.map(&:display_value_w_date)
end

#sw_sort_authorString

Returns a sortable version of the main_author:

main_author + sorting title

which is the mods approximation of the value created for a marc record

Returns:

  • (String)

    value for author_sort field



51
52
53
54
# File 'lib/stanford-mods/concerns/name.rb', line 51

def sw_sort_author
  #  substitute java Character.MAX_CODE_POINT for nil main_author so missing main authors sort last
  "#{sw_main_author || "\u{10FFFF} " }#{sort_title}".gsub(/[[:punct:]]*/, '').strip
end