Class: Watson::FS
Overview
File system utility function class Contains all methods for file access in watson
Constant Summary collapse
- DEBUG =
Debug printing for this class
false
Constants included from Watson
BLUE, BOLD, CYAN, GLOBAL_DEBUG_OFF, GLOBAL_DEBUG_ON, 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
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/watson/fs.rb', line 44 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
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/watson/fs.rb', line 20 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 can be opened if 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 |