Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/keyboard_convertor.rb
Constant Summary collapse
- RU_LAYOUT =
%q/ёЁ"№;:?йцукенгшщзхъфывапролджэячсмитьбю.ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭ\/ЯЧСМИТЬБЮ,/
- EN_LAYOUT =
%q/`~@#$^&qwertyuiop[]asdfghjkl;'zxcvbnm,.\/QWERTYUIOP{}ASDFGHJKL:"|ZXCVBNM<>?/
Instance Method Summary collapse
Instance Method Details
#convert_keyboard(options = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/keyboard_convertor.rb', line 7 def convert_keyboard( = nil) dir = ru_en?() wrong_chars = dir ? RU_LAYOUT : EN_LAYOUT right_chars = dir ? EN_LAYOUT : RU_LAYOUT new_word = self.each_char.map { |char| (i = wrong_chars.index(char)).nil? ? char : right_chars[i] } new_word.join('').force_encoding('UTF-8') end |