Module: BGS::Utilities::Helpers
- Included in:
- BenefitClaim, Job
- Defined in:
- lib/bgs/utilities/helpers.rb
Instance Method Summary collapse
Instance Method Details
#normalize_composite_characters(str) ⇒ Object
6 7 8 9 10 |
# File 'lib/bgs/utilities/helpers.rb', line 6 def normalize_composite_characters(str) # NFKD decomposes composite characters (e.g. ü, ñ) into their individual components, and here, `gsub` # removes any non-ASCII components (e.g. ü -> u; ñ -> n). str&.unicode_normalize(:nfkd)&.gsub(/[^\p{ASCII}]|[`!*%&@^]/, '') end |
#remove_special_characters_from_name(name) ⇒ Object
12 13 14 15 |
# File 'lib/bgs/utilities/helpers.rb', line 12 def remove_special_characters_from_name(name) # Interestingly, BGS permits names with forward slashes and hyphens, but not apostrophes. name&.gsub(%r{[^a-zA-Z\s/-]}, '') end |