Sha256: 3beea2fcbb8630c25294275a8010592455c757638aa9239b3e0318e032d661a2

Contents?: true

Size: 651 Bytes

Versions: 16

Compression:

Stored size: 651 Bytes

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

require 'eprun'

module TwitterCldr
  module Normalization

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

    class << self

      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

    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/lib/twitter_cldr/normalization.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/lib/twitter_cldr/normalization.rb
twitter_cldr-5.2.0 lib/twitter_cldr/normalization.rb
twitter_cldr-5.1.0 lib/twitter_cldr/normalization.rb
twitter_cldr-5.0.0 lib/twitter_cldr/normalization.rb
twitter_cldr-4.4.5 lib/twitter_cldr/normalization.rb
twitter_cldr-4.4.4 lib/twitter_cldr/normalization.rb
twitter_cldr-4.4.3 lib/twitter_cldr/normalization.rb
twitter_cldr-4.4.2 lib/twitter_cldr/normalization.rb
twitter_cldr-4.4.1 lib/twitter_cldr/normalization.rb
twitter_cldr-4.4.0 lib/twitter_cldr/normalization.rb
twitter_cldr-4.3.1 lib/twitter_cldr/normalization.rb
twitter_cldr-4.3.0 lib/twitter_cldr/normalization.rb
twitter_cldr-4.2.0 lib/twitter_cldr/normalization.rb
twitter_cldr-4.1.0 lib/twitter_cldr/normalization.rb
twitter_cldr-4.0.0 lib/twitter_cldr/normalization.rb