I’m building a program that goes thru a file structure, and it will find
the longest filename and biggest files.
Find.find(directory) do |f|
file_sizes[File.size(f)]= f
if File.file?(f)
file_stripper = File.basename(f).delete(".jpg") #FIGURE OUT TO
STRIP THE ExTENSION
file_length[f] = file_stripper
end
end
I got that part, but I can’t seem to be able to strip the extension,
because I don’t want to count the extensions part part of the length.
Can the delete method take regexep? WHat would the regexep for something
like anything after the “.”?
Returns the last component of the filename given in file_name,
which must be formed using forward slashes (``/'') regardless of
the separator used on the local file system. If suffix is given
and present at the end of file_name, it is removed.
File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb"
File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"