Skip to content

Instantly share code, notes, and snippets.

@mfifth
Created October 17, 2015 22:08
Show Gist options
  • Save mfifth/8d6bcb3cb132431a1b03 to your computer and use it in GitHub Desktop.
Save mfifth/8d6bcb3cb132431a1b03 to your computer and use it in GitHub Desktop.
Caesar_Cipher
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