From 86ef38194bf2f5c854cab0adf29984594ee4a6ec Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Sun, 24 Dec 2023 13:26:07 -0600 Subject: RDoc for complex.c --- complex.c | 79 +++++++++++++++++++++++++++++---------------------------------- 1 file changed, 36 insertions(+), 43 deletions(-) (limited to 'complex.c') diff --git a/complex.c b/complex.c index 9057771b5c..d29189e367 100644 --- a/complex.c +++ b/complex.c @@ -1932,9 +1932,9 @@ nilclass_to_c(VALUE self) /* * call-seq: - * num.to_c -> complex + * to_c -> complex * - * Returns the value as a complex. + * Returns +self+ as a Complex object. */ static VALUE numeric_to_c(VALUE self) @@ -2232,32 +2232,30 @@ string_to_c_strict(VALUE self, int raise) /* * call-seq: - * str.to_c -> complex - * - * Returns a complex which denotes the string form. The parser - * ignores leading whitespaces and trailing garbage. Any digit - * sequences can be separated by an underscore. Returns zero for null - * or garbage string. - * - * '9'.to_c #=> (9+0i) - * '2.5'.to_c #=> (2.5+0i) - * '2.5/1'.to_c #=> ((5/2)+0i) - * '-3/2'.to_c #=> ((-3/2)+0i) - * '-i'.to_c #=> (0-1i) - * '45i'.to_c #=> (0+45i) - * '3-4i'.to_c #=> (3-4i) - * '-4e2-4e-2i'.to_c #=> (-400.0-0.04i) - * '-0.0-0.0i'.to_c #=> (-0.0-0.0i) - * '1/2+3/4i'.to_c #=> ((1/2)+(3/4)*i) - * 'ruby'.to_c #=> (0+0i) - * - * Polar form: - * include Math - * "1.0@0".to_c #=> (1+0.0i) - * "1.0@#{PI/2}".to_c #=> (0.0+1i) - * "1.0@#{PI}".to_c #=> (-1+0.0i) - * - * See Kernel.Complex. + * to_c -> complex + * + * Returns +self+ interpreted as a Complex object; + * leading whitespace and trailing garbage are ignored: + * + * '9'.to_c # => (9+0i) + * '2.5'.to_c # => (2.5+0i) + * '2.5/1'.to_c # => ((5/2)+0i) + * '-3/2'.to_c # => ((-3/2)+0i) + * '-i'.to_c # => (0-1i) + * '45i'.to_c # => (0+45i) + * '3-4i'.to_c # => (3-4i) + * '-4e2-4e-2i'.to_c # => (-400.0-0.04i) + * '-0.0-0.0i'.to_c # => (-0.0-0.0i) + * '1/2+3/4i'.to_c # => ((1/2)+(3/4)*i) + * '1.0@0'.to_c # => (1+0.0i) + * "1.0@#{Math::PI/2}".to_c # => (0.0+1i) + * "1.0@#{Math::PI}".to_c # => (-1+0.0i) + * + * Returns \Complex zero if the string cannot be converted: + * + * 'ruby'.to_c # => (0+0i) + * + * See Kernel#Complex. */ static VALUE string_to_c(VALUE self) @@ -2368,9 +2366,9 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass) /* * call-seq: - * num.abs2 -> real + * abs2 -> real * - * Returns square of self. + * Returns the square of +self+. */ static VALUE numeric_abs2(VALUE self) @@ -2380,11 +2378,9 @@ numeric_abs2(VALUE self) /* * call-seq: - * num.arg -> 0 or float - * num.angle -> 0 or float - * num.phase -> 0 or float + * arg -> 0 or Math::PI * - * Returns 0 if the value is positive, pi otherwise. + * Returns zero if +self+ is positive, Math::PI otherwise. */ static VALUE numeric_arg(VALUE self) @@ -2396,10 +2392,9 @@ numeric_arg(VALUE self) /* * call-seq: - * num.rect -> array - * num.rectangular -> array + * rect -> array * - * Returns an array; [num, 0]. + * Returns array [self, 0]. */ static VALUE numeric_rect(VALUE self) @@ -2409,9 +2404,9 @@ numeric_rect(VALUE self) /* * call-seq: - * num.polar -> array + * polar -> array * - * Returns an array; [num.abs, num.arg]. + * Returns array [self.abs, self.arg]. */ static VALUE numeric_polar(VALUE self) @@ -2439,11 +2434,9 @@ numeric_polar(VALUE self) /* * call-seq: - * flo.arg -> 0 or float - * flo.angle -> 0 or float - * flo.phase -> 0 or float + * arg -> 0 or Math::PI * - * Returns 0 if the value is positive, pi otherwise. + * Returns 0 if +self+ is positive, Math::PI otherwise. */ static VALUE float_arg(VALUE self) -- cgit v1.2.3