From: "Eregon (Benoit Daloze) via ruby-core" Date: 2024-08-14T13:20:13+00:00 Subject: [ruby-core:118853] [Ruby master Feature#20676] Pathnames aren't Comparable Issue #20676 has been updated by Eregon (Benoit Daloze). I think we should add `Pathname#start_with?(path)` for convenience, or maybe `Pathname#inside?(path)`. FWIW it already exists in my `path` gem: https://github.com/eregon/path/blob/a5e1d4d35a66466cfe8ab201f67982916cbbe845/lib/path.rb#L91-L96 ---------------------------------------- Feature #20676: Pathnames aren't Comparable https://bugs.ruby-lang.org/issues/20676#change-109420 * Author: gmcgibbon (Gannon McGibbon) * Status: Feedback ---------------------------------------- ���� I was working with Pathnames recently and noticed that I could do: ```rb Pathname("/a/b").to_s <= Pathname("/a/b/c").to_s ``` but could not do: ```rb Pathname("/a/b") <= Pathname("/a/b/c") ``` to check if pathnames are subdirectories of each other. Pathname implements [`<=>`](https://docs.ruby-lang.org/en/master/Pathname.html#method-i-3C-3D-3E) with case insensitive matching for use-cases like this, but does not include Comparable. I think Pathname should include Comparable. I've opened a [PR here](https://github.com/ruby/pathname/pull/40) for your consideration. Thanks! -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/