Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

📤 Morse code encoder and decoder with supports Latin, Cyrillic.

License

Notifications You must be signed in to change notification settings

dionixs/morsify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

87 Commits

Repository files navigation

Morsify

Morsify - это библиотека для конвертирования текста в Азбуку Морзе или наоборот.

Одной из ключевых особенностей gem morsify, является трансляция между азбукой Морзе и кириллицей.

Установка

Добавьте эту строку в Gemfile вашего приложения:

gem 'morsify'

Затем выполните:

$ bundle

Или установите пакет morsify из Rubygems:

gem install morsify

Использование

  • Между одним символом азбуки морзе, используется один пробел.

  • Между словами отступ равен 7 пробелам.

Текст в азбуку Морзе

require 'morsify'
text = 'hello'
Morsify.encode(text)
=> ".... . .-.. .-.. ---"
text = 'текст на русском'
Morsify.encode(text)
=> "- . -.- ... - -. .- .-. ..- ... ... -.- --- --"

Код Морзе в кириллицу

require 'morsify'
text = "- . -.- ... - -. .- .-. ..- ... ... -.- --- --"
Morsify.decode(text, :ru)
=> "ТЕКСТ НА РУССКОМ"

Код Морзе в латиницу

require 'morsify'
text = "... --- ... ... --- ..."
Morsify.decode(text)
 => "SOS SOS"

Код Морзе в WAV File

Сохраняет файл в формате .wav в текущую папку, из которой запущен основной файл программы.

В данной папке, создается подпапка, с именем текущей даты, в формате (ДД-ММ-ГГГГ).

Внутри которой будет сохранен .wav файл, с именем текущего времени, в формате (ЧЧ-ММ-СС).

require 'morsify'
text = "... --- ... ... --- ..."
Morsify.wave(text)
=> "Generate wave file: current_path/Day-Month-Year/Hour-Min-Sec.wav"

Терминал

$> morsify
Select the operation mode: (Use ↑/↓ arrow keys, press Enter to select)
‣ Text to Morse
 Morse to Text
 Text to WAV File
 Exit
$> morsify -h
Usage: morsify [options]
 -h, --help Prints this help
 -e, --encode TEXT Text to Morse
 -d, --decode MORSE_CODE Morse to Text
 -c, --cyrillic
 -w, --wave MORSE_CODE Morse to WAV File
 -v, --version
$> morsify -e "hello" 
=> ".... . .-.. .-.. ---"
$> morsify -d "... --- ..."
=> "SOS"
$> morsify -d ".--. .-. .. .-- . -" -c
=> "ПРИВЕТ"

В случае глобального запуска программы, файл в формате .wav, будет сохранен в домашний каталог.

$> morsify -w '... --- ...'
=> Generate wave file: /home/user/records/06-03-2020/14-10-09.wav

Тесты

bundle exec rake spec

Ресурсы

License

Code released under MIT license.

About

📤 Morse code encoder and decoder with supports Latin, Cyrillic.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /