Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > pathnameライブラリ > Pathnameクラス > <=>

instance method Pathname#<=>

self <=> other -> bool

パス名を比較します。other と同じなら 0 を、ASCII順で self が大きい場合 は正、other が大きい場合は負を返します。大文字小文字は区別されます。 other は Pathname オブジェクトでなければなりません。

パス名の比較は単純にパス文字列の比較によって行われるので、論理的に 同じパスでもパス文字列が違えば異なると判断されます。

[PARAM] other:
比較対象の Pathname オブジェクトを指定します。
require 'pathname'

p Pathname.new("foo/bar") <=> Pathname.new("foo/bar")
p Pathname.new("foo/bar") <=> Pathname.new("foo//bar")
p Pathname.new("foo/../foo/bar") <=> Pathname.new("foo/bar")
=> 0
   1
   -1
class Pathname