This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def namify(value) | |
array = value.split(/\b/) | |
array.each do |e| | |
next if !!e.match(/\A(-|'|’|‘|d|e|o|t|y)\Z/) | |
next if !!e.match(/\A(af|da|de|di|do|du|et|la|le|of|to|zu)\Z/) | |
next if !!e.match(/\A(das|del|den|der|des|dit|dos|lis|lix|til|und|van|von)\Z/) | |
next if !!e.match(/\A(Abdul|Da|De|Della|Der|Di|Du|Fitz|h|La|Ma|Mac|Mak|Mc|O|Van|Vande|Vander|Varta|Vartig)[A-Z\u00c0-\u00cf\u00d0-\u00d6\u00d8-\u00de\u0130\u0152\u0160\u0178\u017d][a-z\u00df\u00e0-\u00ef\u00f0-\u00f6\u00f8-\u00ff\u0131\u0153\u0161\u017e]+/) | |
e.capitalize! | |
end | |
array.join.strip |