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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/keyboard_convertor.rb +12 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1101a39f60420a70fc6e20e9b019d962b5a07531
4
- data.tar.gz: 324cc192680830cc57c5608cc75d6742502aa39c
3
+ metadata.gz: 445fdc63bbdac9cb32fab739a500a74c4d21a893
4
+ data.tar.gz: 7eff1cba72ca7074ef6a027cda3461fc47c8de53
5
5
  SHA512:
6
- metadata.gz: 9957a81e60368e04f753b0be16efbe25726b15ced665bdc0783353abed83557293e378466c9873207523b2e327c22c0038f207e6f89ffd6b8f190a5af66af673
7
- data.tar.gz: 27e38712972f7173e5273a0edbedea0e9f5f3d7fcdd74ad36c234d009c9c8a84c96d3f0e611305d85b000b36436aa69a2cccdab240eba6766dcfe18c14514191
6
+ metadata.gz: d7d7ccee7768e340440ccb286fa3a7bd7508bc5b44aca1645d0172c387f055b5bf4f393935d4a3335791e6a3284073c55365a23f71f201ce61759d0a58a52ae3
7
+ data.tar.gz: b2868f72168c8ab9ce2bfeebc275cc4af52f1e43f5d92a11313632f9c4f017efc1a505e1fafd6de07594d933a93b2bb88c68d7210e314c220797730ebeda12d5
@@ -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 convert_keyboard(option)
7
- data = String.const_get("#{option[:from]}_#{option[:to]}".upcase)
8
- new_word = self.each_char.map do |char|
9
- data[char].nil? ? char : data[char]
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keyboard_convertor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maksim Berjoza