Module: Karamzin
- Includes:
- Config, WordsHelper
- Defined in:
- lib/karamzin.rb,
lib/karamzin/string.rb,
lib/karamzin/version.rb,
lib/karamzin/dictionary.rb,
lib/karamzin/words_helper.rb,
lib/karamzin/config/yaml_loader.rb
Defined Under Namespace
Modules: Config, WordsHelper Classes: Dictionary, String
Constant Summary collapse
- E_LETTER =
'е'
- YO_LETTER =
'ё'
- BIG_E_LETTER =
'Е'
- BIG_YO_LETTER =
'Ё'
- VERSION =
'1.0.3'
Instance Method Summary collapse
Methods included from WordsHelper
#equate_words_register, #filter_words, #first_letter_in
Instance Method Details
#insert(str) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/karamzin.rb', line 17 def insert(str) @dictionary = Dictionary.new 'dictionary' words = filter_words str.split words.each do |word| index_in_dictionary = @dictionary.is_in_dictionary word if index_in_dictionary word_with_yo = make_word_with_yo(word, index_in_dictionary) index = str.index word next if index.nil? str.gsub! str[index..(index + word.length - 1)], equate_words_register(word, word_with_yo) end end str end |
#make_word_with_yo(word, index_in_dictionary) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/karamzin.rb', line 32 def make_word_with_yo(word, index_in_dictionary) word_with_yo = @dictionary[first_letter_in(word)][index_in_dictionary] index = @dictionary.indexes[first_letter_in(word)][index_in_dictionary].to_i letter = word[index] if letter == E_LETTER word_with_yo[index] = YO_LETTER elsif letter == BIG_E_LETTER word_with_yo[index] = BIG_YO_LETTER end word_with_yo end |