Sha256: da354b6b0c5e2af5a19e5bde2a09ec59c8e00cc92352c5f13d13cb8c8d0e0b03

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

# @since Ruby 2.2.0-preview2
class ActiveNormalizer
  module Normalizers
    class Ruby < Normalizer
      def initialize(normalization_form = nil)
        @normalization_form = normalization_form
      end

      def run(text)
        case normalization_form
        when :nfd
          text.unicode_normalize(:nfd)
        when :nfc
          text.unicode_normalize(:nfc)
        when :nfkd
          text.unicode_normalize(:nfkd)
        when :nfkc
          text.unicode_normalize(:nfkc)
        else
          raise_unknown_form_error(normalization_form)
        end
      end

      private

      attr_reader :normalization_form
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_normalizer-1.0.0 lib/active_normalizer/normalizers/ruby.rb