Created
November 8, 2014 21:50
-
-
Save jasonblanchard/11228b6ccaac77670ffe to your computer and use it in GitHub Desktop.
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
| class ROT13 | |
| def self.translate(string) | |
| output = string.split('').map do |character| | |
| if alphabet.include? character | |
| alphabet[(alphabet.index(character) + 13) % 26] | |
| else | |
| character | |
| end | |
| end.join | |
| puts output | |
| end | |
| def self.alphabet | |
| ('a'..'z').to_a | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment