Last active
October 6, 2015 19:18
-
-
Save miguelperez/3040979 to your computer and use it in GitHub Desktop.
Translates your name to a ninja name, Based on this chart https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash3/562718_260591850723037_282005643_n.jpg
This file contains 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 | |
LETTERS = { | |
:a => 'ka', | |
:b => 'zu', | |
:c => 'mi', | |
:d => 'te', | |
:e => 'ku', | |
:f => 'lu', | |
:g => 'ji', | |
:h => 'r', | |
:i => 'ki', | |
:j => 'zu', | |
:k => 'me', | |
:l => 'ta', | |
:m => 'rin', | |
:n => 'to', | |
:o => 'mo', | |
:p => 'no', | |
:q => 'ke', | |
:r => 'shi', | |
:s => 'ari', | |
:t => 'chi', | |
:u => 'do', | |
:v => 'ru', | |
:w => 'mei', | |
:x => 'na', | |
:y => 'fu', | |
:z => 'zi' | |
} | |
unless ARGV.empty? | |
result = '' | |
ARGV.each do |name| | |
name.gsub(/[^\w]?\d?_?/i, "").downcase.each_char do |letter| | |
result += LETTERS[letter.to_sym] | |
end | |
result += " " | |
end | |
puts "Your name #{ARGV.join(" ")} is spelled #{result} in ninja!" | |
else | |
puts "Correct ussage is ruby ninja.rb juan perez" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment