Class: Encrubto::Rot13::Encryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/encrubto/rot13/encryptor.rb

Constant Summary collapse

ORI =
'abcdefghijklmnopqrstuvwxyz'
ROT =
'nopqrstuvwxyzabcdefghijklm'

Instance Method Summary collapse

Instance Method Details

#decrypt(encrypted) ⇒ Object



15
16
17
# File 'lib/encrubto/rot13/encryptor.rb', line 15

def decrypt(encrypted)
  encrypt(encrypted)
end

#encrypt(str) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/encrubto/rot13/encryptor.rb', line 7

def encrypt(str)
  if str.is_a? String
    str.tr("#{ ORI }#{ ORI.upcase }", "#{ ROT }#{ ROT.upcase }")
  else
    raise 'Param must be String!'
  end
end