0.0
No commit activity in last 3 years
No release in over 3 years
Simple Morse Code Encode and Decode Tool
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 2.14
~> 5.11
~> 1.7
~> 0.11
~> 10.0
~> 0.59
~> 0.16

Runtime

~> 0.19
~> 1.0
 Project Readme

MorseCode

Simple Morse Code Encode and Decode Tool

Gem Version Build Status Maintainability Test Coverage GitHub license

Installation

Add this line to your application's Gemfile:

gem 'morse-code-rb'

And then execute:

$ bundle

Or install it yourself as:

$ gem install morse-code-rb

Usage

Encode

require 'morse_code'

content = 'I am Robot.'
MorseCode::Encoder.new(content).encode
=> ".. / .- -- / .-. --- -... --- - .-.-.-"

MorseCode::Encoder.new(content).dit_dah
=> "DITDIT / DITDAH DAHDAH / DITDAHDIT DAHDAHDAH DAHDITDITDIT DAHDAHDAH DAH DITDAHDITDAHDITDAH"

content = 'I am Chinese 我是中国人'
MorseCode::Encoder.new(content).encode
=> ".. / .- -- / -.-. .... .. -. . ... . / --...-....-...- --..--...-.---- -..---...-.--.- -.-.--.------.- -..---.-.---.-."

MorseCode::Encoder.new(content).dit_dah
=> "DITDIT / DITDAH DAHDAH / DAHDITDAHDIT DITDITDITDIT DITDIT DAHDIT DIT DITDITDIT DIT / DAHDAHDITDITDITDAHDITDITDITDITDAHDITDITDITDAH DAHDAHDITDITDAHDAHDITDITDITDAHDITDAHDAHDAHDAH DAHDITDITDAHDAHDAHDITDITDITDAHDITDAHDAHDITDAH DAHDITDAHDITDAHDAHDITDAHDAHDAHDAHDAHDAHDITDAH DAHDITDITDAHDAHDAHDITDAHDITDAHDAHDAHDITDAHDIT"

Generate Wave File

require 'morse_code'

content = 'I am Robot.'
MorseCode::Encoder.new(content).wave
=> "/tmp/morse_code-5b9b3aa176.wav"

you can open wavefile and listen to the morse code sound.

Decode

require 'morse_code'

content = '.. / .- -- / .-. --- -... --- - .-.-.-'
MorseCode::Decoder.new(content).decode
=> "I AM ROBOT."

dit_dah = 'DITDIT / DITDAH DAHDAH / DITDAHDIT DAHDAHDAH DAHDITDITDIT DAHDAHDAH DAH DITDAHDITDAHDITDAH'
MorseCode::Decoder.new(dit_dah).dit_dah_to
=> "I AM ROBOT."

content = '.. / .- -- / -.-. .... .. -. . ... . / --...-....-...- --..--...-.---- -..---...-.--.- -.-.--.------.- -..---.-.---.-.'
MorseCode::Decoder.new(content).decode
=> "I AM CHINESE 我是中国人"

Terminal

$> mc
mc commands:
  mc decode MESSAGE  # decode Morse Code as original message
  mc encode MESSAGE  # encode message as Morse Code
  mc help [COMMAND]  # Describe available commands or one specific command

encode

$> mc help encode
Usage:
  mc encode MESSAGE

Options:
  -d, [--dit-dah], [--no-dit-dah]  # encode DITDAH message
  -w, [--wave], [--no-wave]        # gen morse code wav

encode message as Morse Code
$> mc -e 'I am Robot.'
=> ".. / .- -- / .-. --- -... --- - .-.-.-"

$> mc -e 'I am Robot.' --dit-dah
=> "DITDIT / DITDAH DAHDAH / DITDAHDIT DAHDAHDAH DAHDITDITDIT DAHDAHDAH DAH DITDAHDITDAHDITDAH"

$> mc -e 'I am Chinese 我是中国人'
=> ".. / .- -- / -.-. .... .. -. . ... . / --...-....-...- --..--...-.---- -..---...-.--.- -.-.--.------.- -..---.-.---.-."

$> mc -e -w 'I am Chinese 我是中国人'
=> ".. / .- -- / -.-. .... .. -. . ... . / --...-....-...- --..--...-.---- -..---...-.--.- -.-.--.------.- -..---.-.---.-."
=> "Generate wave file: /tmp/morse_code-0d56cd233e.wav"

you can open wavefile and listen to the morse code sound.

decode

$> mc -d '.. / .- -- / .-. --- -... --- - .-.-.-'
=> "I AM ROBOT."

$> mc -d 'DITDIT / DITDAH DAHDAH / DITDAHDIT DAHDAHDAH DAHDITDITDIT DAHDAHDAH DAH DITDAHDITDAHDITDAH' --dit-dah
=> "I AM ROBOT."

$> mc -d '.. / .- -- / -.-. .... .. -. . ... . / --...-....-...- --..--...-.---- -..---...-.--.- -.-.--.------.- -..---.-.---.-.'
=> "I AM CHINESE 我是中国人"

Contributing

Fork the Project

$ git https://github.com/superiorlu/morse_code.git
$ cd morse_code
$ git remote add upstream https://github.com/superiorlu/morse_code.git

Create a Toptic Branch

$ git checkout master
$ git pull upstream master
$ git checkout -b my-feature-branch

Run Test

$ bundle exec rake test

Make a Pull Request

Click the 'Pull Request' button and fill out the form.

Resource

License

MIT License. See LICENSE for details.