Class: Watson::FS
Overview
File system utility function class Contains all methods for file access in watson
Constant Summary
Constants included from Watson
BLUE, BOLD, CYAN, GRAY, GREEN, MAGENTA, RED, RESET, UNDERLINE, VERSION, WHITE, YELLOW
Class Method Summary collapse
-
.check_dir(dir) ⇒ Object
Check if directory exists and can be opened.
-
.check_file(file) ⇒ Object
Check if file exists and can be opened.
Methods included from Watson
Class Method Details
.check_dir(dir) ⇒ Object
Check if directory exists and can be opened
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/watson/fs.rb', line 41 def check_dir(dir) # Identify method entry debug_print "#{ self } : #{ __method__ }\n" # Error check for input if dir.length == 0 debug_print "No directory specified\n" return false end # Check if directory exists if Dir.exists?(dir) debug_print "#{ dir } exists and opened succesfully\n" return true else debug_print "Could not open #{ dir }, skipping\n" return false end end |
.check_file(file) ⇒ Object
Check if file exists and can be opened
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/watson/fs.rb', line 17 def check_file(file) # Identify method entry debug_print "#{ self } : #{ __method__ }\n" # Error check for input if file.length == 0 debug_print "No file specified\n" return false end # Check if file is actually a file and can be opened if File.file?(file) && File.readable?(file) debug_print "#{ file } exists and opened successfully\n" return true else debug_print "Could not open #{ file }, skipping\n" return false end end |