Module: AtlasEngine::AddressValidation::Normalizer

Extended by:
T::Sig
Included in:
Token::Sequence
Defined in:
app/models/atlas_engine/address_validation/normalizer.rb

Instance Method Summary collapse

Instance Method Details

#normalize(string) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/atlas_engine/address_validation/normalizer.rb', line 14

def normalize(string)
  string
    .gsub("Æ", "AE")
    .gsub("Œ", "OE")
    .gsub("æ", "ae")
    .gsub("œ", "oe")
    .gsub("  ", " ")
    # TODO: Strip hyphens for USPS not zip
    .gsub(/[!@%&"'*,.();:]/, "")
    .downcase
    .tr(T.unsafe(AtlasEngine::ValidationTranscriber::Constants.instance).with_diacritics,
      T.unsafe(AtlasEngine::ValidationTranscriber::Constants.instance).without_diacritics)
end