ruby - Delete file from path value stored in array method fails if file is not present -
i have dynamically generated array of file paths may this:
paths = ["/lib/my_folder/foo", "/lib/my_folder/bar", "/lib/my_folder/baz", ...]
so want do:
for path in paths |path| file.delete(path) #if file exists end
this failing element in array points file no longer there.
i tried:
for path in paths if !path.blank? file.delete(path) end end
but still fails no such file or directory...
error msg.
how can go writing loop dele element(s) left in array without failing?
paths.each { |path| file.delete(path) if file.exists?(path) }
Comments
Post a Comment