    # File lib/facets/core/string/soundex.rb, line 14
      def soundex
        return nil if self.empty?

        str = self.upcase
        last_code = String.soundex_code(str[0,1])
        soundex_code = str[0,1]

        for index in 1...(str.size) do
          return soundex_code if soundex_code.size == 4

          code = String.soundex_code(str[index,1])

          if code == "0" then
            last_code = nil
          elsif code == nil then
            return nil
          elsif code != last_code then
            soundex_code += code
            last_code = code
          end
        end

        return soundex_code + "000"[0,4-soundex_code.size]
      end