Module: MorseWave

Includes:
Telegraph, WaveFile
Defined in:
lib/morsify/morse_wave.rb

Overview

Данный модуль, отвечает за запись фразы, в файл в формате .wav

Constant Summary collapse

ORIGINAL_PATH =

Текущий путь к папке с программой

Pathname(__dir__)
CURRENT_PATH =

Путь необходимый для создания массива путей к файлам. Возвращает в родительский католог

File.expand_path('../../', ORIGINAL_PATH)

Constants included from MorseCode

MorseCode::ENCODE_DICT, MorseCode::EN_DECODE_DICT, MorseCode::LETTER_SPACE, MorseCode::RU_DECODE_DICT

Constants included from MorseDictionaries

MorseDictionaries::LATIN, MorseDictionaries::NUMBERS, MorseDictionaries::PUNCTUATION_MARKS, MorseDictionaries::RUSSIAN

Class Method Summary collapse

Methods included from Telegraph

morse_to_text, text_to_morse

Methods included from MorseCode

choose_dictionary, lang_support?

Class Method Details

.text_to_wave(morse) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/morsify/morse_wave.rb', line 18

def self.text_to_wave(morse)
  text = Telegraph.morse_to_text(morse)

  unless text.nil?
    # разбиваем слово на буквы, включая пробелы
    letters = text.downcase.strip.split('')

    # массив путей к файлам
    paths = to_paths_array(letters)

    # проверка существуют ли файлы по заданному пути
    check_paths(paths)

    # создаем имя будущего файла
    file_of_name = generate_file_name

    # cохраняем файл в формате .wav
    write_to_wave(file_of_name, paths)
  end
end