From ab4a0b4e0ec30fe7567fe6c9ef04d8ff851f256f Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Sun, 21 Dec 2025 15:40:24 +0000 Subject: [PATCH] [DOC] Doc for File::Stat<=> --- file.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/file.c b/file.c index 0fdccb7d14..89294ea009 100644 --- a/file.c +++ b/file.c @@ -605,17 +605,31 @@ statx_mtimespec(const rb_io_stat_data *st) /* * call-seq: - * stat <=> other_stat -> -1, 0, 1, nil + * self <=> other -> -1, 0, 1, or nil * - * Compares File::Stat objects by comparing their respective modification - * times. + * Compares +self+ and +other+, by comparing their modification times; + * that is, by comparing self.mtime and other.mtime. * - * +nil+ is returned if +other_stat+ is not a File::Stat object + * Returns: * - * f1 = File.new("f1", "w") - * sleep 1 - * f2 = File.new("f2", "w") - * f1.stat <=> f2.stat #=> -1 + * - +-1+, if self.mtime is earlier. + * - +0+, if the two values are equal. + * - +1+, if self.mtime is later. + * - +nil+, if +other+ is not a File::Stat object. + * + * Examples: + * + * stat0 = File.stat('README.md') + * stat1 = File.stat('NEWS.md') + * stat0.mtime # => 2025-12-20 15:33:05.6972341 -0600 + * stat1.mtime # => 2025-12-20 16:02:08.2672945 -0600 + * stat0 <=> stat1 # => -1 + * stat0 <=> stat0.dup # => 0 + * stat1 <=> stat0 # => 1 + * stat0 <=> :foo # => nil + * + * \Class \File::Stat includes module Comparable, + * each of whose methods uses File::Stat#<=> for comparison. */ static VALUE