Class: Kiba::Extend::Utils::MarcRoleTermCleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/extend/utils/marc_role_term_cleaner.rb

Overview

Callable service to clean punctuation off end of name string

Since:

  • 4.0.0

Instance Method Summary collapse

Instance Method Details

#call(value) ⇒ String

Parameters:

  • value (String)

Returns:

  • (String)

Since:

  • 4.0.0



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kiba/extend/utils/marc_role_term_cleaner.rb', line 14

def call(value)
  value.sub(/,$/, "")
    .sub(/([^ .].)\.$/, '\1')
    .sub(/^\((.*)\)$/, '\1')
    .sub(/ ?\((work|expression|manifestation|item)\)/, "")
    .sub(/^comp$/i, "compiler")
    .sub(/^comp\. and ed$/i, "compiler|editor")
    .sub(/^ed$/, "editor")
    .sub(/^engr$/, "engraver")
    .sub(/^illus$/, "illustrator")
    .sub(/^pbl$/, "publisher")
    .sub(/^tr$/, "translator")
    # rubocop:todo Layout/LineLength
    .sub(/^(engraver|architect|illustrator|publisher|stereotyper)s$/, '\1')
  # rubocop:enable Layout/LineLength
end