Class: Wixy::Caesar

Inherits:
Object
  • Object
show all
Defined in:
lib/wixy/caesar.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = Config.new) ⇒ Caesar

Returns a new instance of Caesar.



6
7
8
9
# File 'lib/wixy/caesar.rb', line 6

def initialize(config = Config.new)
  @text_alphabet = Alphabet.AZ
  @cipher_alphabet = Alphabet.AZ shift: config.shift
end

Instance Method Details

#decrypt(text) ⇒ Object



15
16
17
# File 'lib/wixy/caesar.rb', line 15

def decrypt(text)
  substitute(text, @cipher_alphabet, @text_alphabet)
end

#encrypt(text) ⇒ Object



11
12
13
# File 'lib/wixy/caesar.rb', line 11

def encrypt(text)
  substitute(text, @text_alphabet, @cipher_alphabet)
end