I am trying to come up with a mechanism that will check whether a list of known directories exist before creating them on the system.
To do so, I wrote the following; but it does not really work. I believe there must be an issue with the each loop but I could not fix it on my own.
I would like to make sure that none of the directory in the array exist before creating.
Many thanks for your help!
method_options path: :string
def create_folders
if profile_folders_exist?
puts "Profile folders exist already"
else
copy_profile_folders
puts "Profile folders created successfully"
end
end
private
def profile_folders_exist?
profile_folders.each do |f|
File.directory?(File.join(install_path, f))
end
end
def profile_folders
return ["Pictures", "Notes", "Signatures"]
end
def install_path
Pathname.new(options[:path].to_s)
end