Class: EnigmaEncrypto::FileHandler

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

Instance Method Summary collapse

Instance Method Details

#check_file_useability(file1, file2) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/enigma_encrypto/file_handler.rb', line 15

def check_file_useability(file1, file2)
  messages
  if (!(File.exists?file1) || (File.zero? file1))
    puts @msg1
    return false
  end 
  if File.exists?file2
    puts @msg2 + "\n" + @msg3
    operation_collector
  end
end

#messagesObject

file1 represents file to be read from file2 represents file to be written to



8
9
10
11
12
13
# File 'lib/enigma_encrypto/file_handler.rb', line 8

def messages
  @msg1 = "File to be read doesnt exist or is empty.\nTry again with an existing file"
  @msg2 = "File to be written to already exists!"
  @msg3 = "To cancel operation, Press 'C'\nTo overwrite File, Type 'W'"
  @msg4 = "Incorrect Entry"
end

#read(msg) ⇒ Object



27
28
29
# File 'lib/enigma_encrypto/file_handler.rb', line 27

def read(msg)
  readable = File.open(msg, "r")
end

#writer(msg, word) ⇒ Object



31
32
33
34
35
# File 'lib/enigma_encrypto/file_handler.rb', line 31

def writer(msg, word)
  writable = File.open(msg, "a")
  writable.write(word)
  writable.close
end