module MazeCrosser::FileChecker
Module containing a file validator.
Constants
- ALLOWED_EXTENSIONS
Public Instance Methods
check(file)
click to toggle source
# File lib/maze_crosser/file_checker.rb, line 6 def check(file) raise ArgumentError, 'Invalid file' unless valid_file? file file end
Private Instance Methods
allowed_extension?(file)
click to toggle source
# File lib/maze_crosser/file_checker.rb, line 22 def allowed_extension?(file) file =~ /^.+\.(#{ALLOWED_EXTENSIONS.join('|')})$/ end
file_exists?(file)
click to toggle source
# File lib/maze_crosser/file_checker.rb, line 18 def file_exists?(file) File.file? file end
valid_file?(file)
click to toggle source
# File lib/maze_crosser/file_checker.rb, line 14 def valid_file?(file) file_exists?(file) && allowed_extension?(file) end