class MonitorTypeDir
A directory class for checking how many files are in a directory
Public Instance Methods
derived_value()
click to toggle source
# File lib/monitor_type/dir.rb, line 38 def derived_value Dir.glob("#{@path}/*").length end
extract_params()
click to toggle source
Extract parameters
@param [String] path Path to directory to check
# File lib/monitor_type/dir.rb, line 8 def extract_params if @params[:path].nil? string = "*** Dir parameter missing, path\n" \ '*** :path => <path to directory to be monitored>' fail MonitorTypeParameterMissingError, string end @path = @params[:path] @context_sentence = "Checking number of files in, #{@path}" end
setup()
click to toggle source
# File lib/monitor_type/dir.rb, line 19 def setup input_dir = Dir.new(@path) @path = input_dir.path @params[:dir] = input_dir rescue Errno::ENOENT str = "***** Directory does not exist, #{@path}.\n" \ "***** Create the directory, #{@path}, and try again.\n" \ "***** eg, mkdir #{@path}" raise MonitorTypeExceptionHandled, str rescue Errno::ENOTDIR str = '***** The specified path does not point to a ' \ "directory, #{@path}.\n" \ '***** Either repoint path to a directory, ' \ "or remove, #{@path}, and create it as a directory.\n" \ "***** eg, rm #{@path} && mkdir #{@path}" raise MonitorTypeExceptionHandled, str end