Module: TwitterCldr::Normalization

Defined in:
lib/twitter_cldr/normalization.rb

Constant Summary collapse

VALID_NORMALIZERS =
[:nfd, :nfkd, :nfc, :nfkc]
DEFAULT_NORMALIZER =
:nfd

Class Method Summary collapse

Class Method Details

.normalize(string, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/twitter_cldr/normalization.rb', line 16

def normalize(string, options = {})
  form = options.fetch(:using, DEFAULT_NORMALIZER).to_s.downcase.to_sym

  if VALID_NORMALIZERS.include?(form)
    Eprun.normalize(string, form)
  else
    raise ArgumentError.new("#{form.inspect} is not a valid normalizer (valid normalizers are #{VALID_NORMALIZERS.join(', ')})")
  end
end