Created
February 13, 2013 19:13
-
-
Save shaiguitar/4947232 to your computer and use it in GitHub Desktop.
://sphotos-b.xx.fbcdn.net/hphotos-snc6/377635_345841315524300_1034340001_n.jpg
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
# inspired by https://sphotos-b.xx.fbcdn.net/hphotos-snc6/377635_345841315524300_1034340001_n.jpg | |
class NinjaName | |
class << self | |
MAPPING = { | |
"a" => "ka" , | |
"b" => "zu" , | |
"c" => "mi" , | |
"d" => "te" , | |
"e" => "ku" , | |
"f" => "lu" , | |
"g" => "ji" , | |
"h" => "ri" , | |
"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" | |
} | |
def convert(name) | |
ninja_name = "" ; i = 0 | |
name.each_char {|c| | |
ninja_chars = MAPPING[c] | |
if ninja_chars | |
ninja_name << ninja_chars | |
i += 1 | |
unless i == name.size # last letter | |
ninja_name << "-" | |
end | |
else | |
raise "Could not find mapping for #{c}" | |
end | |
} | |
ninja_name | |
end | |
def usage | |
"ninja.rb <name_to_convert>" | |
end | |
end | |
end | |
if __FILE__==$0 | |
if ARGV.empty? | |
puts NinjaName.usage | |
else | |
puts NinjaName.convert(ARGV[0]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment