I was working with Pathnames recently and noticed that I could do:
Pathname("/a/b").to_s<=Pathname("/a/b/c").to_s
but could not do:
Pathname("/a/b")<=Pathname("/a/b/c")
to check if pathnames are subdirectories of each other.
Pathname implements <=> 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 for your consideration.
Pathname class already has this kind of logic in the <=> function
It doesn't, at least not in the way the original poster asked for or as @nobu (Nobuyoshi Nakada) suggested. This is clear from @byroot's example above.
The Pathname#<=> method only does a case-insensitive string comparison of the pathnames, which does not imply any subdirectory relationship between the two.
It looks like I got it wrong. <=> does case-sensitive matching and doesn't behave the way I thought it did. Generally, I agree Pathname#inside?(path) would be a good addition that addresses my concern.