Sha256: b418feb8b48a6ff731fd17a1cecb5c297c00f69fb6e177db85cdb496783f3d6e

Contents?: true

Size: 688 Bytes

Versions: 26

Compression:

Stored size: 688 Bytes

Contents

# encoding: utf-8
#
module CharacterSubstituters # :nodoc:all
  # Substitutes Umlauts like
  # ä, ö, ü => ae, oe, ue.
  # (and more, see specs)
  #
  class WestEuropean
    
    def initialize
      @chars = ActiveSupport::Multibyte.proxy_class
    end
    
    def substitute text
      trans = @chars.new(text).normalize(:kd)
      
      # substitute special cases
      #
      trans.gsub!('ß', 'ss')
      
      # substitute umlauts (of A,O,U,a,o,u)
      #
      trans.gsub!(/([AOUaou])\314\210/u, '\1e')
      
      # get rid of ecutes, graves and …
      #
      trans.unpack('U*').select { |cp|
        cp < 0x0300 || cp > 0x035F
      }.pack('U*')
    end
    
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
picky-1.5.2 lib/picky/character_substituters/west_european.rb
picky-1.5.1 lib/picky/character_substituters/west_european.rb
picky-1.5.0 lib/picky/character_substituters/west_european.rb
picky-1.4.3 lib/picky/character_substituters/west_european.rb
picky-1.4.2 lib/picky/character_substituters/west_european.rb
picky-1.4.1 lib/picky/character_substituters/west_european.rb
picky-1.4.0 lib/picky/character_substituters/west_european.rb
picky-1.3.4 lib/picky/character_substituters/west_european.rb
picky-1.3.3 lib/picky/character_substituters/west_european.rb
picky-1.3.2 lib/picky/character_substituters/west_european.rb
picky-1.3.1 lib/picky/character_substituters/west_european.rb
picky-1.3.0 lib/picky/character_substituters/west_european.rb
picky-1.2.4 lib/picky/character_substituters/west_european.rb
picky-1.2.3 lib/picky/character_substituters/west_european.rb
picky-1.2.2 lib/picky/character_substituters/west_european.rb
picky-1.2.1 lib/picky/character_substituters/west_european.rb
picky-1.2.0 lib/picky/character_substituters/west_european.rb
picky-1.1.7 lib/picky/character_substituters/west_european.rb
picky-1.1.6 lib/picky/character_substituters/west_european.rb
picky-1.1.5 lib/picky/character_substituters/west_european.rb