Module: KingDta::Helper

Included in:
Account, Booking, Dta
Defined in:
lib/king_dta/helper.rb

Instance Method Summary collapse

Instance Method Details

#convert_text(text) ⇒ Object

Zeichen umsetzen gemäss DTA-Norm



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/king_dta/helper.rb', line 5

def convert_text( text)
  text = text.to_s
  return text if text.empty?
  raise "Text kein String >#{text}< (#{text.class})" unless text.kind_of?( String ) # not possible
  text.gsub!('Ä', 'AE')
  text.gsub!('Ü', 'UE')
  text.gsub!('Ö', 'OE')
  text.gsub!('ä', 'AE')
  text.gsub!('ü', 'UE')
  text.gsub!('ö', 'OE')
  text.gsub!('ß', 'SS')

  text = I18n.transliterate(text)

  text.gsub! /[^a-zA-Z0-9\ \.\,\&\-\/\+\*\$\%]/, '' # Remove all invalid chars
  text.upcase.strip
end