class Caesar_Cipher
	def initialize(plain, cipher_step)
		@plain = plain
		@cipher_step = cipher_step
		@crypted = crypt(@plain, @cipher_step)
	end

	def crypt(plain, cipher_step)
		letters = plain.split(//)
		letters.map do |letter|
			if letter.scan(/\w/).length == 1

				cipher_step.times do
					if (letter != 'z') && (letter != 'Z')
						letter.next!
					elsif (letter == 'z')
						letter = 'a'
					elsif (letter == 'Z')
						letter = 'A'
					end
				end
			end
		end

		letters.join("")
	end

	def out
		puts @crypted
	end
end

mydecl = Caesar_Cipher.new("What a string!", 5)
mydecl.out