Implementing the Caesar Cipher in Ruby

Caesar cipher is the simplest and most widely known encryption technique. It is also known as Caesar’s cipher, shift cipher, Caesar’s code, Caesar shift, or ROT N (ROT13 is the most famous one, shifting letters by 13).

It is very simple because it just works for letters between A and Z, ignoring all special characters, such as dots, whitespaces, question marks, and special letters, like Ç or Á.

Starting our implementation, we need to create a class that will know what we want to cipher and how many rotations we will do.