システム上にディレクトリを作成する前に、既知のディレクトリのリストが存在するかどうかを確認するメカニズムを考え出そうとしています。
そのために、私は次のように書きました。しかし、実際には機能しません。each ループに問題があるに違いないと思いますが、自分で修正できませんでした。
作成する前に、配列内のディレクトリが存在しないことを確認したいと思います。
助けてくれて本当にありがとうございます!
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