Last active
August 10, 2016 23:38
-
-
Save dylanerichards/d6631f8cf42e2cb88dacd0d08c33303c to your computer and use it in GitHub Desktop.
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
class WakaWaka | |
attr_reader :code | |
def initialize(code) | |
@code = code | |
end | |
MAPPINGS = { | |
'<' => 'Waka', | |
'>' => 'waka', | |
'!' => 'bang', | |
"'" => 'tick', | |
'#' => 'hash', | |
'^' => 'Caret', | |
'"' => 'quote', | |
'`' => 'back-tick', | |
'$' => 'dollar', | |
'-' => 'dash', | |
'!' => 'Bang', | |
'=' => 'equal', | |
'@' => 'at', | |
'_' => 'underscore', | |
'%' => 'Percent', | |
'~' => 'tilde', | |
'4' => 'four', | |
} | |
def translate | |
@code.each do |symbol| | |
puts "#{symbol}: #{MAPPINGS.fetch(symbol, "unknown symbol")}" | |
end | |
end | |
end | |
waka_code = WakaWaka.new(["<", ">", "!", "*", "'", "'", "#", "^", '"', "`", "$", "$", "-", "!", "*", "=", "@", "$", "_", "%", "*", "<", ">", "~", "#", "4"]) | |
p waka_code.translate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment