Sha256: e2e769bc4d43d287bb20bd9abc3a56b82d79c8ce31f724b12ebed29d153cfb8c

Contents?: true

Size: 594 Bytes

Versions: 11

Compression:

Stored size: 594 Bytes

Contents

require 'java'

module UNF
  class Normalizer
    def initialize()
      @normalizer = java.text.Normalizer
    end

    def normalize(string, normalization_form)
      @normalizer.normalize(string, form(normalization_form))
    end

    private

    def form(symbol)
      case symbol
      when :nfc
        @normalizer::Form::NFC
      when :nfd
        @normalizer::Form::NFD
      when :nfkc
        @normalizer::Form::NFKC
      when :nfkd
        @normalizer::Form::NFKD
      else
        raise ArgumentError, "unknown normalization form: #{symbol.inspect}"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
unf-0.1.0 lib/unf/normalizer_jruby.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/unf-0.0.5/lib/unf/normalizer_jruby.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/unf-0.0.5/lib/unf/normalizer_jruby.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/unf-0.0.5/lib/unf/normalizer_jruby.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/unf-0.0.5/lib/unf/normalizer_jruby.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/unf-0.0.5/lib/unf/normalizer_jruby.rb
unf-0.0.5-jruby lib/unf/normalizer_jruby.rb
unf-0.0.5 lib/unf/normalizer_jruby.rb
domo-0.0.5 vendor/bundle/ruby/1.9.1/gems/unf-0.0.4/lib/unf/normalizer_jruby.rb
unf-0.0.4 lib/unf/normalizer_jruby.rb
unf-0.0.3 lib/unf_jruby.rb