pathname
pathname copied to clipboard
Pathname represents the name of a file or directory on the filesystem, but not the file itself.
There's an ordering difference when using the built-in `` vs the string representation one: ```ruby > Pathname.new(File.expand_path('.')).glob('**/*.rb').sort.first(5) => [#, #, #, #, #] > Pathname.new(File.expand_path('.')).glob('**/*.rb').sort_by(&:to_s).first(5) => [#, #, #, #,...
I often need to *add* an extension (be it `.tmp` or `.bak` for example). Writing `path.sub_ext("#{path.extname}.tmp")` is weird. Likewise for `path.sub(/\z/, '.tmp')`. And unfortunately `+` and `/` have exactly the...
Suggested in https://github.com/ruby/pathname/issues/37 I have wanted this too. I didn't add the `~` operator suggested on that issue but not opposed to it. Not sure this needed to be in...
I love Pathname. I love FileUtils. Let's bring these two classes EVEN CLOSER TOGETHER by adding some tragically missing helpers. I would be happy to create a PR for this...
``` $ ruby -v ruby 3.5.0dev (2025-10-09T08:06:20Z master a29c90c3b0) +PRISM [x86_64-linux] $ gem install pathname Building native extensions. This could take a while... Successfully installed pathname-0.4.0 1 gem installed $...
To quote the original issue - I love Pathname. I love FileUtils. Let's bring these two classes EVEN CLOSER TOGETHER by adding some tragically missing helpers. Something like this, perhaps?