keyboard_convertor 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/keyboard_convertor.rb +12 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 445fdc63bbdac9cb32fab739a500a74c4d21a893
|
4
|
+
data.tar.gz: 7eff1cba72ca7074ef6a027cda3461fc47c8de53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7d7ccee7768e340440ccb286fa3a7bd7508bc5b44aca1645d0172c387f055b5bf4f393935d4a3335791e6a3284073c55365a23f71f201ce61759d0a58a52ae3
|
7
|
+
data.tar.gz: b2868f72168c8ab9ce2bfeebc275cc4af52f1e43f5d92a11313632f9c4f017efc1a505e1fafd6de07594d933a93b2bb88c68d7210e314c220797730ebeda12d5
|
data/lib/keyboard_convertor.rb
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
class String
|
3
3
|
|
4
|
-
RU_EN = { 'q' => 'й', 'w' => 'ц', 'e' => 'у', 'r' => 'к', 't' => 'е', 'y' => 'н', 'u' => 'г', 'i' => 'ш', 'o' => 'щ', 'p' => 'з', '[' => 'х', ']' => 'ъ', 'a' => 'ф', 's' => 'ы', 'd' => 'в', 'f' => 'а', 'g' => 'п', 'h' => 'р', 'j' => 'о', 'k' => 'л', 'l' => 'д', ';' => 'ж', '\'' => 'э', '\\' => 'ё', 'z' => 'я', 'x' => 'ч', 'c' => 'с', 'v' => 'м', 'b' => 'и', 'n' => 'т', 'm' => 'ь', ',' => 'б', '.' => 'ю', 'Q' => 'Й', 'W' => 'Ц', 'E' => 'У', 'R' => 'К', 'T' => 'Е', 'Y' => 'Н', 'I' => 'Ш', 'O' => 'Щ', 'P' => 'З', '{' => 'Х', '}' => 'Ъ', 'A' => 'Ф', 'S' => 'Ы', 'D' => 'В', 'F' => 'А', 'G' => 'П', 'H' => 'Р', 'J' => 'О', 'K' => 'Л', 'L' => 'Д', ':' => 'Ж', '"' => 'Э', '|' => 'Ё', 'Z' => 'Я', 'X' => 'Ч', 'C' => 'С', 'V' => 'М', 'B' => 'И', 'N' => 'Т', 'M' => 'Ь', '<' => 'Б', '>' => 'Ю'}
|
4
|
+
RU_EN = { 'q' => 'й', 'w' => 'ц', 'e' => 'у', 'r' => 'к', 't' => 'е', 'y' => 'н', 'u' => 'г', 'i' => 'ш', 'o' => 'щ', 'p' => 'з', '[' => 'х', ']' => 'ъ', 'a' => 'ф', 's' => 'ы', 'd' => 'в', 'f' => 'а', 'g' => 'п', 'h' => 'р', 'j' => 'о', 'k' => 'л', 'l' => 'д', ';' => 'ж', '\'' => 'э', '\\' => 'ё', 'z' => 'я', 'x' => 'ч', 'c' => 'с', 'v' => 'м', 'b' => 'и', 'n' => 'т', 'm' => 'ь', ',' => 'б', '.' => 'ю', 'Q' => 'Й', 'W' => 'Ц', 'E' => 'У', 'R' => 'К', 'T' => 'Е', 'Y' => 'Н', 'I' => 'Ш', 'O' => 'Щ', 'P' => 'З', '{' => 'Х', '}' => 'Ъ', 'A' => 'Ф', 'S' => 'Ы', 'D' => 'В', 'F' => 'А', 'G' => 'П', 'H' => 'Р', 'J' => 'О', 'K' => 'Л', 'L' => 'Д', ':' => 'Ж', '"' => 'Э', '|' => 'Ё', 'Z' => 'Я', 'X' => 'Ч', 'C' => 'С', 'V' => 'М', 'B' => 'И', 'N' => 'Т', 'M' => 'Ь', '<' => 'Б', '>' => 'Ю' }
|
5
5
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def data(options)
|
7
|
+
if options && options[:from] && options[:to]
|
8
|
+
String.const_get("#{options[:from]}_#{options[:to]}".upcase)
|
9
|
+
else
|
10
|
+
RU_EN
|
10
11
|
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def convert_keyboard(options = nil)
|
15
|
+
data = self.data(options)
|
16
|
+
|
17
|
+
new_word = self.each_char.map { |char| data[char].nil? ? char : data[char] }
|
11
18
|
new_word.join('').force_encoding('UTF-8')
|
12
19
|
end
|
13
20
|
|