Skip to content
Ruby gem to read and write Morse code
Branch: master
Clone or download
Latest commit cbd0317 May 3, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Explicit require. Nov 9, 2010
.gitignore gitignore Nov 9, 2010
.travis.yml latest ruby releases May 3, 2019
Gemfile uses https rubygems source Nov 16, 2015
Gemfile.lock update dependencies May 3, 2019
MIT-LICENSE.txt updates rake & copyright notice Jan 17, 2019
README.rdoc links reference doc Nov 26, 2017
Rakefile Travis CI ready Aug 2, 2011
telegraph.gemspec removes deprecated option Apr 5, 2019



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:

$ [sudo] 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://'


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:

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 = =>'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"



Juanjo Bazán


Copyright © 2013 - ∞ Juanjo Bazán


Released under the MIT license.

You can’t perform that action at this time.