Created
October 17, 2015 22:08
-
-
Save mfifth/8d6bcb3cb132431a1b03 to your computer and use it in GitHub Desktop.
Caesar_Cipher
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 Caesar_Cipher | |
def initialize(string, shift) | |
@string = string | |
@shift = shift | |
@lowercase = ("a".."z") | |
@uppercase = ("A".."Z") | |
@output = [] | |
end | |
def letter_shift | |
string.chars do |a| | |
if a.between?("x".."z") | |
do ("x" = "a", "y" = "b", "z" = "c") | |
output << a.shift | |
else | |
output << a.shift | |
elsif | |
if a.between?("X".."Z") | |
do ("X" = "A", "Y" = "B", "Z" = "C") | |
output << a.shift | |
else | |
output << a.shift | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment