Sha256: 199b0c6ecca80d3956aa4778e5987468daa19c9c93daef40d2b7f044d0050938

Contents?: true

Size: 650 Bytes

Versions: 23

Compression:

Stored size: 650 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

23 entries across 23 versions & 2 rubygems

Version Path
twitter_cldr-3.6.0 lib/twitter_cldr/normalization.rb
twitter_cldr-3.5.0 lib/twitter_cldr/normalization.rb
twitter_cldr-3.4.0 lib/twitter_cldr/normalization.rb
twitter_cldr-3.3.0 lib/twitter_cldr/normalization.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/normalization.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/normalization.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/lib/twitter_cldr/normalization.rb
twitter_cldr-3.2.1 lib/twitter_cldr/normalization.rb
twitter_cldr-3.2.0 lib/twitter_cldr/normalization.rb
twitter_cldr-3.1.2 lib/twitter_cldr/normalization.rb
twitter_cldr-3.1.1 lib/twitter_cldr/normalization.rb
twitter_cldr-3.1.0 lib/twitter_cldr/normalization.rb
twitter_cldr-3.0.10 lib/twitter_cldr/normalization.rb
twitter_cldr-3.0.9 lib/twitter_cldr/normalization.rb
twitter_cldr-3.0.8 lib/twitter_cldr/normalization.rb
twitter_cldr-3.0.7 lib/twitter_cldr/normalization.rb
twitter_cldr-3.0.6 lib/twitter_cldr/normalization.rb
twitter_cldr-3.0.5 lib/twitter_cldr/normalization.rb
twitter_cldr-3.0.4 lib/twitter_cldr/normalization.rb
twitter_cldr-3.0.3 lib/twitter_cldr/normalization.rb