Last active
January 1, 2016 10:59
-
-
Save RoxasShadow/8134730 to your computer and use it in GitHub Desktop.
Morse: reinvented / based on https://github.com/hydride0/things/blob/master/morse.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| ########################################### | |
| # | |
| alpha = { :a=>'._', :b=>'_...', # | |
| :c=>'_._.', :d=>'_..', # | |
| :e=>'.', :f=>'.._.', # | |
| :g=>'__.', :h=>'....', # | |
| :i=>'..', :j=>'.___', # | |
| :k=>'_._', :l=>'._..', # | |
| :m=>'__', :n=>'_.', # | |
| :o=>'___', :p=>'.__.', # | |
| :q=>'__._', :r=>'._.', # | |
| :s=>'...', :t=>'_', # | |
| :u=>'.._', :v=>'..._', # | |
| :w=>'.__', :x=>'_.._', # | |
| :y=>'_.__', :z=>'__..', # | |
| :'1'=>'.____', :'2'=>'..___', # | |
| :'3'=>'...__', :'4'=>'...._', # | |
| :'5'=>'.....', :'6'=>'_....', # | |
| :'7'=>'__...', :'8'=>'___..', # | |
| :'9'=>'____.', :'0'=>'_____', # | |
| :' '=>'.....' # | |
| } # | |
| # | |
| ########################################### | |
| puts ''.tap { |s| ARGV.join.downcase.chars.each { |x| s << "#{alpha[x.to_sym]} " if alpha.has_key? x.to_sym } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment