From 344c16eba40457f937c6558299f52bc97d6f3ce7 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 30 Jan 2023 13:14:18 -0800 Subject: [PATCH] Avoid using a weird syntax for documentation Following up 465bd972ec2. If the actual implementation still resides in C, it should be documented in C just like all other places. --- numeric.c | 17 ++++++++++++++++- numeric.rb | 22 ---------------------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/numeric.c b/numeric.c index 15729e4728..d1316eb6e2 100644 --- a/numeric.c +++ b/numeric.c @@ -6008,7 +6008,22 @@ rb_int_s_isqrt(VALUE self, VALUE num) } } -/* :nodoc: */ +/* + * call-seq: + * Integer.try_convert(object) -> object, integer, or nil + * + * If +object+ is an \Integer object, returns +object+. + * Integer.try_convert(1) # => 1 + * + * Otherwise if +object+ responds to :to_int, + * calls object.to_int and returns the result. + * Integer.try_convert(1.25) # => 1 + * + * Returns +nil+ if +object+ does not respond to :to_int + * Integer.try_convert([]) # => nil + * + * Raises an exception unless object.to_int returns an \Integer object. + */ static VALUE int_s_try_convert(VALUE self, VALUE num) { diff --git a/numeric.rb b/numeric.rb index 49e14bff49..e852c85bf9 100644 --- a/numeric.rb +++ b/numeric.rb @@ -296,28 +296,6 @@ class Integer end end -# call-seq: -# Integer.try_convert(object) -> object, integer, or nil -# -# If +object+ is an \Integer object, returns +object+. -# Integer.try_convert(1) # => 1 -# -# Otherwise if +object+ responds to :to_int, -# calls object.to_int and returns the result. -# Integer.try_convert(1.25) # => 1 -# -# Returns +nil+ if +object+ does not respond to :to_int -# Integer.try_convert([]) # => nil -# -# Raises an exception unless object.to_int returns an \Integer object. -# -def Integer.try_convert(num) -=begin - Primitive.attr! 'inline' - Primitive.cexpr! 'rb_check_integer_type(num)' -=end -end if false - class Float # # call-seq: