Method: String#fix_name_modifiers!
- Defined in:
- lib/name_tamer/string.rb
#fix_name_modifiers! ⇒ Object
Fixes for name modifiers followed by space Also replaces spaces with non-breaking spaces Fixes for name modifiers followed by an apostrophe, e.g. d’Artagnan, Commedia dell’Arte
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/name_tamer/string.rb', line 114 def fix_name_modifiers! NAME_MODIFIERS.each do |modifier| gsub!(/((?:[[:space:]]|^)#{modifier})([[:space:]]+|-)/) do |_| "#{Regexp.last_match[1].rstrip.downcase}#{Regexp.last_match[2].tr(ASCII_SPACE, NONBREAKING_SPACE)}" end end fix_apostrophe_modifiers! self # Allows chaining end |