I am trying to write a small ruby ββscript that determines whether a given argument is a file or directory based on a string containing trailing /or not.
To be clear, I'm not interested in knowing if a file or directory exists, in other words, AFAIK File.directory?will not work for me.
Also, all the methods that I found in the standard library, for example Pathname.basename, automatically delete the trailing one /(if any). So, let's do something like this:
arg = "/foo/bar/baz/"
if File.basename(arg).include?("/")
puts "#{arg} is a directory"
end
does not work.
Is there a concise way to do this? Did I miss something?
I would prefer not to resort to regular expression, if at all possible.