class Cryptogram::Ciphers::BaseCipher

Public Class Methods

new(alphabet:) click to toggle source

@param [Array, Symbol] alphabet Array of chars or presetted alphabet name

# File lib/cryptogram/ciphers/base_cipher.rb, line 8
def initialize(alphabet:)
  @alphabet = initialize_alphabet(alphabet)
end

Public Instance Methods

decrypt() click to toggle source
# File lib/cryptogram/ciphers/base_cipher.rb, line 16
def decrypt
  raise NotImplementedError
end
encrypt() click to toggle source
# File lib/cryptogram/ciphers/base_cipher.rb, line 12
def encrypt
  raise NotImplementedError
end

Private Instance Methods

initialize_alphabet(alphabet) click to toggle source
# File lib/cryptogram/ciphers/base_cipher.rb, line 22
def initialize_alphabet(alphabet)
  case alphabet
  when Array
    alphabet
  when Symbol
    Cryptogram::Presets::Alphabets.fetch(alphabet)
  else
    raise ArgumentError, "Unsupported alphabet class: #{alphabet.class}"
  end
end