From 2d70aa7ce4ad07750989760ce77294b227b2589b Mon Sep 17 00:00:00 2001 From: shinokaro Date: Tue, 28 May 2024 23:53:57 +0900 Subject: [PATCH] Enabled uniq method by changing Ocran::Pathname comparison method Changed the basis of the comparison method from `==` to `eql?`, enabling the `uniq` method on arrays of `Pathname` objects. - Defined the `eql?` method to check the equality of `Pathname` objects. - Redefined `==` and `===` methods as aliases of `eql?`. - Added comments to the `eql?` method to explain that this method enables the `uniq` method on arrays of `Pathname` objects. --- bin/ocran | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/ocran b/bin/ocran index 35345bd..8e0923e 100644 --- a/bin/ocran +++ b/bin/ocran @@ -49,19 +49,20 @@ module Ocran end end - # Checks if two Ocran::Pathname objects are equal, considering the file system's + # Checks if two Pathname objects are equal, considering the file system's # case sensitivity and path separators. Returns false if the other object is not - # an Ocran::Pathname. - def ==(other) - return false unless other.is_a?(Ocran::Pathname) + # an Pathname. + # This method enables the use of the `uniq` method on arrays of Pathname objects. + def eql?(other) + return false unless other.is_a?(Pathname) a = to_posix b = other.to_posix pathequal(a, b) end - alias === == - alias eql? == + alias == eql? + alias === eql? # The drive_letter? method retrieves the drive letter from the current path # in a Windows environment. This method returns the drive letter as a string