Class: EnigmaEncrypto::FileHandler
- Inherits:
-
Object
- Object
- EnigmaEncrypto::FileHandler
- Defined in:
- lib/enigma_encrypto/file_handler.rb
Instance Method Summary collapse
- #check_file_useability(file1, file2) ⇒ Object
-
#messages ⇒ Object
file1 represents file to be read from file2 represents file to be written to.
- #read(msg) ⇒ Object
- #writer(msg, word) ⇒ Object
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) if (!(File.exists?file1) || (File.zero? file1)) puts @msg1 return false end if File.exists?file2 puts @msg2 + "\n" + @msg3 operation_collector end end |
#messages ⇒ Object
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 @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 |