Class: Cli

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

Instance Method Summary collapse

Constructor Details

#initializeCli

Returns a new instance of Cli.



4
5
6
7
8
9
# File 'lib/cli.rb', line 4

def initialize
  shift_amount = get_shift_amount
  plaintext = get_plain_text
  cipher = create_cipher(shift_amount, plaintext)
  display_encrypted_text(cipher)
end

Instance Method Details

#create_cipher(shift_amount, plaintext) ⇒ Object



21
22
23
# File 'lib/cli.rb', line 21

def create_cipher(shift_amount, plaintext)
  Cipher.new(shift_amount, plaintext)
end

#display_encrypted_text(cipher) ⇒ Object



25
26
27
# File 'lib/cli.rb', line 25

def display_encrypted_text(cipher)
  puts cipher.encrypt
end

#get_plain_textObject



16
17
18
19
# File 'lib/cli.rb', line 16

def get_plain_text
  puts "What message do you want to encyrpt?"
  gets.chomp
end

#get_shift_amountObject



11
12
13
14
# File 'lib/cli.rb', line 11

def get_shift_amount
  puts "What amount do you want to shift the cipher by? (0-25)"
  gets.chomp.to_i
end