All Projects → xuanxu → telegraph

xuanxu / telegraph

Licence: MIT License
Ruby gem to read and write Morse code

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to telegraph

cmorse
A simple text to Morse code converter
Stars: ✭ 23 (+64.29%)
Mutual labels:  morse-code, morse
morse
Morse Code Library in Go
Stars: ✭ 75 (+435.71%)
Mutual labels:  morse-code, morse
Hello-Morse-OpenCV
Morse Code detection with eyes using Computer Vision
Stars: ✭ 46 (+228.57%)
Mutual labels:  morse-code
kochmorse
A simple morse tutor using the Koch method.
Stars: ✭ 56 (+300%)
Mutual labels:  morse-code
attic
A collection of personal tiny tools - mirror of https://gitlab.com/hydrargyrum/attic
Stars: ✭ 17 (+21.43%)
Mutual labels:  morse-code
InternetTelegraph
Source code for the One-Button Internet Telegraph
Stars: ✭ 15 (+7.14%)
Mutual labels:  morse-code
52-Weeks-of-Pi
Inspired by Shekhar Gulati's "52 technologies in 2016", I've decided to set a goal of 52 Pi ideas over the next year.
Stars: ✭ 54 (+285.71%)
Mutual labels:  morse-code
mrs testbed
Multi-robot Exploration Testbed
Stars: ✭ 26 (+85.71%)
Mutual labels:  morse
halp
Display a message in morse code on your capslock LED, keyboard backlight or using your screen brightness!
Stars: ✭ 25 (+78.57%)
Mutual labels:  morse-code
MorseCodeReceiver-UWP
💡 An UWP app which can translate the light sensor data into Morse code on mobile device.
Stars: ✭ 14 (+0%)
Mutual labels:  morse-code
morsemoji
Translate text to morse code, but the morse code is emojis
Stars: ✭ 48 (+242.86%)
Mutual labels:  morse-code
morse-pro
Library for manipulating Morse code text and sound. Understands prosigns and Farnsworth speed. Can create WAV files and analyse input from the microphone or audio files.
Stars: ✭ 85 (+507.14%)
Mutual labels:  morse

Telegraph

Telegraph is a Ruby gem that provides straightforward text-to-morse and morse-to-text translators

It uses as reference the document ‘RECOMMENDATION ITU-R M.1677’ from the International Telecommunication Union, Radiocommunication Sector (ITU-R), the United Nations agency for information and communication technology issues.

Gem Version Build status

Getting started

Install the gem:

$ gem install telegraph

Then depending on your project you may:

require the gem (if a ruby project):

require 'telegraph'

or add it to your Gemfile (if you're on Rails):

gem 'telegraph', :git => 'git://github.com/xuanxu/telegraph.git'

Usage

The simplest way to read or write morse code is using directly the two methods defined in Telegraph:

# Converts text to morse characters:
Telegraph.text_to_morse("Hello world")  #=> ".... . .-.. .-.. ---       .-- --- .-. .-.. -.."

# Reads morse characters into text:
Telegraph.morse_to_text(".... . .-.. .-.. ---       .-- --- .-. .-.. -..")  #=> hello world"

In the Telegraph module you will find defined also the most commonly used prosigns:

# Error sign:
Telegraph::Error    #=> "........"

#The complete list of prosigns:
Telegraph::Error
Telegraph::Understood
Telegraph::Invitation_to_transmit
Telegraph::Wait
Telegraph::End_of_work
Telegraph::Starting_signal

All the generated morse code will use the character '.' as short signal (aka dot) and the character '-' as long signal (aka dash).

If you need to write or read using different characters as short and long signals you can do it instantiating your own Telegraph::MorseTransmission class:

# User defined dot & dash (:short and :long defaults to '.' and '-')
morser = Telegraph::MorseTransmission.new(:short =>'x', :long => '3')

and then using the methods to read/write:

# write morse code with custom signals
morser.text_to_morse("Hello world")  #=> "xxxx x x3xx x3xx 333       x33 333 x3x x3xx 3xx"

# read morse code with custom signals
morser.morse_to_text("xxxx x x3xx x3xx 333       x33 333 x3x x3xx 3xx")  #=> hello world"
morser.error    #=> "xxxxxxxx"

Credits

Author

Juanjo Bazán

Copyright

Copyright © 2013 - ∞ Juanjo Bazán

License

Released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].