rbs 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +5 -0
  3. data/CHANGELOG.md +23 -0
  4. data/README.md +6 -1
  5. data/core/array.rbs +2866 -1086
  6. data/core/basic_object.rbs +150 -30
  7. data/core/binding.rbs +33 -0
  8. data/core/builtin.rbs +4 -4
  9. data/core/class.rbs +43 -5
  10. data/core/comparable.rbs +57 -0
  11. data/core/complex.rbs +170 -4
  12. data/core/constants.rbs +51 -0
  13. data/core/deprecated.rbs +7 -0
  14. data/core/dir.rbs +305 -20
  15. data/core/encoding.rbs +472 -77
  16. data/core/enumerable.rbs +2173 -234
  17. data/core/enumerator.rbs +448 -182
  18. data/core/env.rbs +448 -1
  19. data/core/errno.rbs +1 -10
  20. data/core/errors.rbs +152 -2
  21. data/core/exception.rbs +201 -127
  22. data/core/false_class.rbs +27 -0
  23. data/core/fiber.rbs +118 -37
  24. data/core/fiber_error.rbs +8 -9
  25. data/core/file.rbs +1059 -139
  26. data/core/file_test.rbs +287 -32
  27. data/core/float.rbs +776 -300
  28. data/core/gc.rbs +185 -34
  29. data/core/global_variables.rbs +5 -1
  30. data/core/hash.rbs +1582 -649
  31. data/core/integer.rbs +974 -204
  32. data/core/io/buffer.rbs +710 -0
  33. data/core/io/wait.rbs +29 -8
  34. data/core/io.rbs +2438 -417
  35. data/core/kernel.rbs +2315 -316
  36. data/core/marshal.rbs +37 -2
  37. data/core/match_data.rbs +123 -6
  38. data/core/math.rbs +126 -6
  39. data/core/method.rbs +226 -102
  40. data/core/module.rbs +421 -45
  41. data/core/nil_class.rbs +64 -0
  42. data/core/numeric.rbs +620 -142
  43. data/core/object.rbs +453 -81
  44. data/core/object_space.rbs +92 -2
  45. data/core/proc.rbs +482 -285
  46. data/core/process.rbs +443 -34
  47. data/core/ractor.rbs +232 -9
  48. data/core/random.rbs +151 -52
  49. data/core/range.rbs +885 -160
  50. data/core/rational.rbs +122 -6
  51. data/core/rb_config.rbs +14 -4
  52. data/core/refinement.rbs +44 -0
  53. data/core/regexp.rbs +156 -14
  54. data/core/ruby_vm.rbs +42 -3
  55. data/core/signal.rbs +78 -39
  56. data/core/string.rbs +2123 -567
  57. data/core/string_io.rbs +204 -0
  58. data/core/struct.rbs +283 -28
  59. data/core/symbol.rbs +304 -30
  60. data/core/thread.rbs +1288 -688
  61. data/core/thread_group.rbs +66 -10
  62. data/core/time.rbs +643 -217
  63. data/core/trace_point.rbs +100 -12
  64. data/core/true_class.rbs +24 -0
  65. data/core/unbound_method.rbs +73 -7
  66. data/core/warning.rbs +37 -12
  67. data/docs/CONTRIBUTING.md +40 -34
  68. data/docs/stdlib.md +3 -102
  69. data/lib/rbs/annotate/annotations.rb +197 -0
  70. data/lib/rbs/annotate/formatter.rb +80 -0
  71. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  72. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  73. data/lib/rbs/annotate.rb +6 -0
  74. data/lib/rbs/cli.rb +45 -1
  75. data/lib/rbs/definition_builder.rb +5 -1
  76. data/lib/rbs/location_aux.rb +12 -0
  77. data/lib/rbs/prototype/rb.rb +12 -0
  78. data/lib/rbs/version.rb +1 -1
  79. data/sig/annotate/annotations.rbs +102 -0
  80. data/sig/annotate/formatter.rbs +24 -0
  81. data/sig/annotate/rdoc_annotater.rbs +82 -0
  82. data/sig/annotate/rdoc_source.rbs +30 -0
  83. data/sig/cli.rbs +2 -0
  84. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  85. data/sig/location.rbs +6 -0
  86. data/sig/method_types.rbs +5 -1
  87. data/sig/polyfill.rbs +78 -0
  88. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  89. data/stdlib/abbrev/0/array.rbs +26 -0
  90. data/stdlib/base64/0/base64.rbs +31 -0
  91. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  92. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  93. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  94. data/stdlib/cgi/0/core.rbs +59 -0
  95. data/stdlib/coverage/0/coverage.rbs +164 -2
  96. data/stdlib/csv/0/csv.rbs +2862 -398
  97. data/stdlib/date/0/date.rbs +483 -25
  98. data/stdlib/date/0/date_time.rbs +187 -12
  99. data/stdlib/dbm/0/dbm.rbs +152 -17
  100. data/stdlib/digest/0/digest.rbs +146 -0
  101. data/stdlib/erb/0/erb.rbs +65 -245
  102. data/stdlib/fiber/0/fiber.rbs +73 -91
  103. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  104. data/stdlib/find/0/find.rbs +9 -0
  105. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  106. data/stdlib/io-console/0/io-console.rbs +227 -15
  107. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  108. data/stdlib/json/0/json.rbs +1146 -144
  109. data/stdlib/logger/0/formatter.rbs +24 -0
  110. data/stdlib/logger/0/log_device.rbs +64 -0
  111. data/stdlib/logger/0/logger.rbs +165 -13
  112. data/stdlib/logger/0/period.rbs +10 -0
  113. data/stdlib/logger/0/severity.rbs +26 -0
  114. data/stdlib/monitor/0/monitor.rbs +163 -0
  115. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  116. data/stdlib/net-http/0/net-http.rbs +1492 -683
  117. data/stdlib/nkf/0/nkf.rbs +372 -0
  118. data/stdlib/objspace/0/objspace.rbs +149 -90
  119. data/stdlib/openssl/0/openssl.rbs +8108 -71
  120. data/stdlib/optparse/0/optparse.rbs +487 -19
  121. data/stdlib/pathname/0/pathname.rbs +425 -124
  122. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  123. data/stdlib/prime/0/integer-extension.rbs +20 -2
  124. data/stdlib/prime/0/prime.rbs +88 -21
  125. data/stdlib/pstore/0/pstore.rbs +102 -0
  126. data/stdlib/pty/0/pty.rbs +64 -14
  127. data/stdlib/resolv/0/resolv.rbs +420 -31
  128. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  129. data/stdlib/rubygems/0/config_file.rbs +33 -1
  130. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  131. data/stdlib/rubygems/0/installer.rbs +13 -1
  132. data/stdlib/rubygems/0/path_support.rbs +4 -1
  133. data/stdlib/rubygems/0/platform.rbs +5 -1
  134. data/stdlib/rubygems/0/request_set.rbs +44 -2
  135. data/stdlib/rubygems/0/requirement.rbs +65 -2
  136. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  137. data/stdlib/rubygems/0/source_list.rbs +13 -0
  138. data/stdlib/rubygems/0/specification.rbs +21 -1
  139. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  140. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  141. data/stdlib/rubygems/0/version.rbs +60 -157
  142. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  143. data/stdlib/set/0/set.rbs +420 -106
  144. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  145. data/stdlib/singleton/0/singleton.rbs +20 -0
  146. data/stdlib/socket/0/addrinfo.rbs +210 -9
  147. data/stdlib/socket/0/basic_socket.rbs +103 -11
  148. data/stdlib/socket/0/ip_socket.rbs +31 -9
  149. data/stdlib/socket/0/socket.rbs +586 -38
  150. data/stdlib/socket/0/tcp_server.rbs +22 -2
  151. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  152. data/stdlib/socket/0/udp_socket.rbs +25 -2
  153. data/stdlib/socket/0/unix_server.rbs +22 -2
  154. data/stdlib/socket/0/unix_socket.rbs +45 -5
  155. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  156. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  157. data/stdlib/time/0/time.rbs +208 -116
  158. data/stdlib/timeout/0/timeout.rbs +10 -0
  159. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  160. data/stdlib/tsort/0/cyclic.rbs +1 -0
  161. data/stdlib/tsort/0/interfaces.rbs +1 -0
  162. data/stdlib/tsort/0/tsort.rbs +42 -0
  163. data/stdlib/uri/0/common.rbs +57 -8
  164. data/stdlib/uri/0/file.rbs +55 -109
  165. data/stdlib/uri/0/ftp.rbs +6 -3
  166. data/stdlib/uri/0/generic.rbs +556 -327
  167. data/stdlib/uri/0/http.rbs +26 -115
  168. data/stdlib/uri/0/https.rbs +8 -102
  169. data/stdlib/uri/0/ldap.rbs +143 -137
  170. data/stdlib/uri/0/ldaps.rbs +8 -102
  171. data/stdlib/uri/0/mailto.rbs +3 -0
  172. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  173. data/stdlib/uri/0/ws.rbs +6 -3
  174. data/stdlib/uri/0/wss.rbs +5 -3
  175. data/stdlib/yaml/0/dbm.rbs +151 -87
  176. data/stdlib/yaml/0/store.rbs +6 -0
  177. data/stdlib/zlib/0/zlib.rbs +90 -31
  178. metadata +17 -5
  179. data/lib/rbs/location.rb +0 -221
data/core/numeric.rbs CHANGED
@@ -1,3 +1,4 @@
1
+ # <!-- rdoc-file=numeric.c -->
1
2
  # Numeric is the class from which all higher-level numeric classes should
2
3
  # inherit.
3
4
  #
@@ -69,17 +70,206 @@
69
70
  # puts tally * 2 #=> "||||"
70
71
  # puts tally > 1 #=> true
71
72
  #
73
+ # ## What's Here
74
+ #
75
+ # First, what's elsewhere. Class Numeric:
76
+ #
77
+ # * Inherits from [class
78
+ # Object](Object.html#class-Object-label-What-27s+Here).
79
+ # * Includes [module
80
+ # Comparable](Comparable.html#module-Comparable-label-What-27s+Here).
81
+ #
82
+ #
83
+ # Here, class Numeric provides methods for:
84
+ #
85
+ # * [Querying](#class-Numeric-label-Querying)
86
+ # * [Comparing](#class-Numeric-label-Comparing)
87
+ # * [Converting](#class-Numeric-label-Converting)
88
+ # * [Other](#class-Numeric-label-Other)
89
+ #
90
+ #
91
+ # ### Querying
92
+ #
93
+ # #finite?
94
+ # : Returns true unless `self` is infinite or not a number.
95
+ #
96
+ # #infinite?
97
+ # : Returns -1, `nil` or +1, depending on whether `self` is
98
+ # `-Infinity<tt>, finite, or <tt>+Infinity`.
99
+ #
100
+ # #integer?
101
+ # : Returns whether `self` is an integer.
102
+ #
103
+ # #negative?
104
+ # : Returns whether `self` is negative.
105
+ #
106
+ # #nonzero?
107
+ # : Returns whether `self` is not zero.
108
+ #
109
+ # #positive?
110
+ # : Returns whether `self` is positive.
111
+ #
112
+ # #real?
113
+ # : Returns whether `self` is a real value.
114
+ #
115
+ # #zero?
116
+ # : Returns whether `self` is zero.
117
+ #
118
+ #
119
+ #
120
+ # ### Comparing
121
+ #
122
+ # [<=>](#method-i-3C-3D-3E)
123
+ # : Returns:
124
+ #
125
+ # * -1 if `self` is less than the given value.
126
+ # * 0 if `self` is equal to the given value.
127
+ # * 1 if `self` is greater than the given value.
128
+ # * `nil` if `self` and the given value are not comparable.
129
+ #
130
+ # #eql?
131
+ # : Returns whether `self` and the given value have the same value and
132
+ # type.
133
+ #
134
+ #
135
+ #
136
+ # ### Converting
137
+ #
138
+ # #% (aliased as #modulo)
139
+ # : Returns the remainder of `self` divided by the given value.
140
+ #
141
+ # #-@
142
+ # : Returns the value of `self`, negated.
143
+ #
144
+ # #abs (aliased as #magnitude)
145
+ # : Returns the absolute value of `self`.
146
+ #
147
+ # #abs2
148
+ # : Returns the square of `self`.
149
+ #
150
+ # #angle (aliased as #arg and #phase)
151
+ # : Returns 0 if `self` is positive, Math::PI otherwise.
152
+ #
153
+ # #ceil
154
+ # : Returns the smallest number greater than or equal to `self`, to a
155
+ # given precision.
156
+ #
157
+ # #coerce
158
+ # : Returns array `[coerced_self, coerced_other]` for the given other
159
+ # value.
160
+ #
161
+ # #conj (aliased as #conjugate)
162
+ # : Returns the complex conjugate of `self`.
163
+ #
164
+ # #denominator
165
+ # : Returns the denominator (always positive) of the Rational
166
+ # representation of `self`.
167
+ #
168
+ # #div
169
+ # : Returns the value of `self` divided by the given value and converted
170
+ # to an integer.
171
+ #
172
+ # #divmod
173
+ # : Returns array `[quotient, modulus]` resulting from dividing `self` the
174
+ # given divisor.
175
+ #
176
+ # #fdiv
177
+ # : Returns the Float result of dividing `self` by the given divisor.
178
+ #
179
+ # #floor
180
+ # : Returns the largest number less than or equal to `self`, to a given
181
+ # precision.
182
+ #
183
+ # #i
184
+ # : Returns the Complex object `Complex(0, self)`. the given value.
185
+ #
186
+ # #imaginary (aliased as #imag)
187
+ # : Returns the imaginary part of the `self`.
188
+ #
189
+ # #numerator
190
+ # : Returns the numerator of the Rational representation of `self`; has
191
+ # the same sign as `self`.
192
+ #
193
+ # #polar
194
+ # : Returns the array `[self.abs, self.arg]`.
195
+ #
196
+ # #quo
197
+ # : Returns the value of `self` divided by the given value.
198
+ #
199
+ # #real
200
+ # : Returns the real part of `self`.
201
+ #
202
+ # #rect (aliased as #rectangular)
203
+ # : Returns the array `[self, 0]`.
204
+ #
205
+ # #remainder
206
+ # : Returns `self-arg*(self/arg).truncate` for the given `arg`.
207
+ #
208
+ # #round
209
+ # : Returns the value of `self` rounded to the nearest value for the given
210
+ # a precision.
211
+ #
212
+ # #to_c
213
+ # : Returns the Complex representation of `self`.
214
+ #
215
+ # #to_int
216
+ # : Returns the Integer representation of `self`, truncating if necessary.
217
+ #
218
+ # #truncate
219
+ # : Returns `self` truncated (toward zero) to a given precision.
220
+ #
221
+ #
222
+ #
223
+ # ### Other
224
+ #
225
+ # #clone
226
+ # : Returns `self`; does not allow freezing.
227
+ #
228
+ # #dup (aliased as #+@)
229
+ # : Returns `self`.
230
+ #
231
+ # #step
232
+ # : Invokes the given block with the sequence of specified numbers.
233
+ #
72
234
  class Numeric
73
235
  include Comparable
74
236
 
75
237
  public
76
238
 
77
- # `x.modulo(y)` means `x-y*(x/y).floor`.
239
+ # <!--
240
+ # rdoc-file=numeric.c
241
+ # - self % other -> real_numeric
242
+ # -->
243
+ # Returns `self` modulo `other` as a real number.
244
+ #
245
+ # Of the Core and Standard Library classes, only Rational uses this
246
+ # implementation.
78
247
  #
79
- # Equivalent to `num.divmod(numeric)[1]`.
248
+ # For Rational `r` and real number `n`, these expressions are equivalent:
249
+ #
250
+ # c % n
251
+ # c-n*(c/n).floor
252
+ # c.divmod(n)[1]
80
253
  #
81
254
  # See Numeric#divmod.
82
255
  #
256
+ # Examples:
257
+ #
258
+ # r = Rational(1, 2) # => (1/2)
259
+ # r2 = Rational(2, 3) # => (2/3)
260
+ # r % r2 # => (1/2)
261
+ # r % 2 # => (1/2)
262
+ # r % 2.0 # => 0.5
263
+ #
264
+ # r = Rational(301,100) # => (301/100)
265
+ # r2 = Rational(7,5) # => (7/5)
266
+ # r % r2 # => (21/100)
267
+ # r % -r2 # => (-119/100)
268
+ # (-r) % r2 # => (119/100)
269
+ # (-r) %-r2 # => (-21/100)
270
+ #
271
+ # Numeric#modulo is an alias for Numeric#%.
272
+ #
83
273
  def %: (Numeric) -> Numeric
84
274
 
85
275
  # Performs addition: the class of the resulting object depends on the class of
@@ -87,7 +277,11 @@ class Numeric
87
277
  #
88
278
  def +: (Numeric) -> Numeric
89
279
 
90
- # Unary Plus---Returns the receiver.
280
+ # <!--
281
+ # rdoc-file=numeric.c
282
+ # - +self -> self
283
+ # -->
284
+ # Returns `self`.
91
285
  #
92
286
  def +@: () -> Numeric
93
287
 
@@ -96,165 +290,267 @@ class Numeric
96
290
  #
97
291
  def -: (Numeric) -> Numeric
98
292
 
293
+ # <!--
294
+ # rdoc-file=numeric.c
295
+ # - -self -> numeric
296
+ # -->
99
297
  # Unary Minus---Returns the receiver, negated.
100
298
  #
101
299
  def -@: () -> Numeric
102
300
 
103
- # Returns zero if `number` equals `other`, otherwise returns `nil`.
301
+ # <!--
302
+ # rdoc-file=numeric.c
303
+ # - self <=> other -> zero or nil
304
+ # -->
305
+ # Returns zero if `self` is the same as `other`, `nil` otherwise.
306
+ #
307
+ # No subclass in the Ruby Core or Standard Library uses this implementation.
104
308
  #
105
309
  def <=>: (Numeric other) -> Integer
106
310
 
107
- # Returns the absolute value of `num`.
311
+ # <!--
312
+ # rdoc-file=numeric.c
313
+ # - abs -> numeric
314
+ # -->
315
+ # Returns the absolute value of `self`.
108
316
  #
109
- # 12.abs #=> 12
110
- # (-34.56).abs #=> 34.56
111
- # -34.56.abs #=> 34.56
317
+ # 12.abs #=> 12
318
+ # (-34.56).abs #=> 34.56
319
+ # -34.56.abs #=> 34.56
112
320
  #
113
321
  # Numeric#magnitude is an alias for Numeric#abs.
114
322
  #
115
323
  def abs: () -> Numeric
116
324
 
325
+ # <!--
326
+ # rdoc-file=complex.c
327
+ # - num.abs2 -> real
328
+ # -->
117
329
  # Returns square of self.
118
330
  #
119
331
  def abs2: () -> Numeric
120
332
 
333
+ # <!-- rdoc-file=complex.c -->
121
334
  # Returns 0 if the value is positive, pi otherwise.
122
335
  #
123
336
  def angle: () -> Numeric
124
337
 
338
+ # <!--
339
+ # rdoc-file=complex.c
340
+ # - num.arg -> 0 or float
341
+ # - num.angle -> 0 or float
342
+ # - num.phase -> 0 or float
343
+ # -->
125
344
  # Returns 0 if the value is positive, pi otherwise.
126
345
  #
127
346
  alias arg angle
128
347
 
129
- # Returns the smallest number greater than or equal to `num` with a precision of
130
- # `ndigits` decimal digits (default: 0).
348
+ # <!--
349
+ # rdoc-file=numeric.c
350
+ # - ceil(digits = 0) -> integer or float
351
+ # -->
352
+ # Returns the smallest number that is greater than or equal to `self` with a
353
+ # precision of `digits` decimal digits.
131
354
  #
132
- # Numeric implements this by converting its value to a Float and invoking
355
+ # Numeric implements this by converting `self` to a Float and invoking
133
356
  # Float#ceil.
134
357
  #
135
358
  def ceil: () -> Integer
136
359
  | (Integer digits) -> (Integer | Numeric)
137
360
 
138
- # If `numeric` is the same type as `num`, returns an array `[numeric, num]`.
139
- # Otherwise, returns an array with both `numeric` and `num` represented as Float
140
- # objects.
361
+ # <!--
362
+ # rdoc-file=numeric.c
363
+ # - coerce(other) -> array
364
+ # -->
365
+ # Returns a 2-element array containing two numeric elements, formed from the two
366
+ # operands `self` and `other`, of a common compatible type.
367
+ #
368
+ # Of the Core and Standard Library classes, Integer, Rational, and Complex use
369
+ # this implementation.
370
+ #
371
+ # Examples:
372
+ #
373
+ # i = 2 # => 2
374
+ # i.coerce(3) # => [3, 2]
375
+ # i.coerce(3.0) # => [3.0, 2.0]
376
+ # i.coerce(Rational(1, 2)) # => [0.5, 2.0]
377
+ # i.coerce(Complex(3, 4)) # Raises RangeError.
378
+ #
379
+ # r = Rational(5, 2) # => (5/2)
380
+ # r.coerce(2) # => [(2/1), (5/2)]
381
+ # r.coerce(2.0) # => [2.0, 2.5]
382
+ # r.coerce(Rational(2, 3)) # => [(2/3), (5/2)]
383
+ # r.coerce(Complex(3, 4)) # => [(3+4i), ((5/2)+0i)]
141
384
  #
142
- # This coercion mechanism is used by Ruby to handle mixed-type numeric
143
- # operations: it is intended to find a compatible common type between the two
144
- # operands of the operator.
385
+ # c = Complex(2, 3) # => (2+3i)
386
+ # c.coerce(2) # => [(2+0i), (2+3i)]
387
+ # c.coerce(2.0) # => [(2.0+0i), (2+3i)]
388
+ # c.coerce(Rational(1, 2)) # => [((1/2)+0i), (2+3i)]
389
+ # c.coerce(Complex(3, 4)) # => [(3+4i), (2+3i)]
145
390
  #
146
- # 1.coerce(2.5) #=> [2.5, 1.0]
147
- # 1.2.coerce(3) #=> [3.0, 1.2]
148
- # 1.coerce(2) #=> [2, 1]
391
+ # Raises an exception if any type conversion fails.
149
392
  #
150
393
  def coerce: (Numeric) -> [ Numeric, Numeric ]
151
394
 
395
+ # <!-- rdoc-file=complex.c -->
152
396
  # Returns self.
153
397
  #
154
398
  def conj: () -> Numeric
155
399
 
400
+ # <!--
401
+ # rdoc-file=complex.c
402
+ # - num.conj -> self
403
+ # - num.conjugate -> self
404
+ # -->
156
405
  # Returns self.
157
406
  #
158
407
  def conjugate: () -> Numeric
159
408
 
409
+ # <!--
410
+ # rdoc-file=rational.c
411
+ # - num.denominator -> integer
412
+ # -->
160
413
  # Returns the denominator (always positive).
161
414
  #
162
415
  def denominator: () -> Integer
163
416
 
164
- # Uses `/` to perform division, then converts the result to an integer. Numeric
165
- # does not define the `/` operator; this is left to subclasses.
417
+ # <!--
418
+ # rdoc-file=numeric.c
419
+ # - div(other) -> integer
420
+ # -->
421
+ # Returns the quotient `self/other` as an integer (via `floor`), using method
422
+ # `/` in the derived class of `self`. (Numeric itself does not define method
423
+ # `/`.)
166
424
  #
167
- # Equivalent to `num.divmod(numeric)[0]`.
168
- #
169
- # See Numeric#divmod.
425
+ # Of the Core and Standard Library classes, Float, Rational, and Complex use
426
+ # this implementation.
170
427
  #
171
428
  def div: (Numeric) -> Integer
172
429
 
173
- # Returns an array containing the quotient and modulus obtained by dividing
174
- # `num` by `numeric`.
175
- #
176
- # If `q, r = x.divmod(y)`, then
177
- #
178
- # q = floor(x/y)
179
- # x = q*y + r
180
- #
181
- # The quotient is rounded toward negative infinity, as shown in the following
182
- # table:
183
- #
184
- # a | b | a.divmod(b) | a/b | a.modulo(b) | a.remainder(b)
185
- # ------+-----+---------------+---------+-------------+---------------
186
- # 13 | 4 | 3, 1 | 3 | 1 | 1
187
- # ------+-----+---------------+---------+-------------+---------------
188
- # 13 | -4 | -4, -3 | -4 | -3 | 1
189
- # ------+-----+---------------+---------+-------------+---------------
190
- # -13 | 4 | -4, 3 | -4 | 3 | -1
191
- # ------+-----+---------------+---------+-------------+---------------
192
- # -13 | -4 | 3, -1 | 3 | -1 | -1
193
- # ------+-----+---------------+---------+-------------+---------------
194
- # 11.5 | 4 | 2, 3.5 | 2.875 | 3.5 | 3.5
195
- # ------+-----+---------------+---------+-------------+---------------
196
- # 11.5 | -4 | -3, -0.5 | -2.875 | -0.5 | 3.5
197
- # ------+-----+---------------+---------+-------------+---------------
198
- # -11.5 | 4 | -3, 0.5 | -2.875 | 0.5 | -3.5
199
- # ------+-----+---------------+---------+-------------+---------------
200
- # -11.5 | -4 | 2, -3.5 | 2.875 | -3.5 | -3.5
201
- #
202
- # Examples
203
- #
204
- # 11.divmod(3) #=> [3, 2]
205
- # 11.divmod(-3) #=> [-4, -1]
206
- # 11.divmod(3.5) #=> [3, 0.5]
207
- # (-11).divmod(3.5) #=> [-4, 3.0]
208
- # 11.5.divmod(3.5) #=> [3, 1.0]
430
+ # <!--
431
+ # rdoc-file=numeric.c
432
+ # - divmod(other) -> array
433
+ # -->
434
+ # Returns a 2-element array `[q, r]`, where
435
+ #
436
+ # q = (self/other).floor # Quotient
437
+ # r = self % other # Remainder
438
+ #
439
+ # Of the Core and Standard Library classes, only Rational uses this
440
+ # implementation.
441
+ #
442
+ # Examples:
443
+ #
444
+ # Rational(11, 1).divmod(4) # => [2, (3/1)]
445
+ # Rational(11, 1).divmod(-4) # => [-3, (-1/1)]
446
+ # Rational(-11, 1).divmod(4) # => [-3, (1/1)]
447
+ # Rational(-11, 1).divmod(-4) # => [2, (-3/1)]
448
+ #
449
+ # Rational(12, 1).divmod(4) # => [3, (0/1)]
450
+ # Rational(12, 1).divmod(-4) # => [-3, (0/1)]
451
+ # Rational(-12, 1).divmod(4) # => [-3, (0/1)]
452
+ # Rational(-12, 1).divmod(-4) # => [3, (0/1)]
453
+ #
454
+ # Rational(13, 1).divmod(4.0) # => [3, 1.0]
455
+ # Rational(13, 1).divmod(Rational(4, 11)) # => [35, (3/11)]
209
456
  #
210
457
  def divmod: (Numeric) -> [ Numeric, Numeric ]
211
458
 
212
- # Returns `true` if `num` and `numeric` are the same type and have equal values.
213
- # Contrast this with Numeric#==, which performs type conversions.
459
+ # <!--
460
+ # rdoc-file=numeric.c
461
+ # - eql?(other) -> true or false
462
+ # -->
463
+ # Returns `true` if `self` and `other` are the same type and have equal values.
464
+ #
465
+ # Of the Core and Standard Library classes, only Integer, Rational, and Complex
466
+ # use this implementation.
467
+ #
468
+ # Examples:
214
469
  #
215
- # 1 == 1.0 #=> true
216
- # 1.eql?(1.0) #=> false
217
- # 1.0.eql?(1.0) #=> true
470
+ # 1.eql?(1) # => true
471
+ # 1.eql?(1.0) # => false
472
+ # 1.eql?(Rational(1, 1)) # => false
473
+ # 1.eql?(Complex(1, 0)) # => false
474
+ #
475
+ # Method `eql?` is different from +==+ in that `eql?` requires matching types,
476
+ # while +==+ does not.
218
477
  #
219
478
  def eql?: (untyped) -> bool
220
479
 
221
- # Returns float division.
480
+ # <!--
481
+ # rdoc-file=numeric.c
482
+ # - fdiv(other) -> float
483
+ # -->
484
+ # Returns the quotient `self/other` as a float, using method `/` in the derived
485
+ # class of `self`. (Numeric itself does not define method `/`.)
486
+ #
487
+ # Of the Core and Standard Library classes, only BigDecimal uses this
488
+ # implementation.
222
489
  #
223
490
  def fdiv: (Numeric) -> Numeric
224
491
 
492
+ # <!--
493
+ # rdoc-file=numeric.rb
494
+ # - num.finite? -> true or false
495
+ # -->
225
496
  # Returns `true` if `num` is a finite number, otherwise returns `false`.
226
497
  #
227
498
  def finite?: () -> bool
228
499
 
229
- # Returns the largest number less than or equal to `num` with a precision of
230
- # `ndigits` decimal digits (default: 0).
500
+ # <!--
501
+ # rdoc-file=numeric.c
502
+ # - floor(digits = 0) -> integer or float
503
+ # -->
504
+ # Returns the largest number that is less than or equal to `self` with a
505
+ # precision of `digits` decimal digits.
231
506
  #
232
- # Numeric implements this by converting its value to a Float and invoking
507
+ # Numeric implements this by converting `self` to a Float and invoking
233
508
  # Float#floor.
234
509
  #
235
510
  def floor: () -> Integer
236
511
  | (Integer digits) -> Numeric
237
512
 
238
- # Returns the corresponding imaginary number. Not available for complex numbers.
513
+ # <!--
514
+ # rdoc-file=numeric.c
515
+ # - i -> complex
516
+ # -->
517
+ # Returns `Complex(0, self)`:
239
518
  #
240
- # -42.i #=> (0-42i)
241
- # 2.0.i #=> (0+2.0i)
519
+ # 2.i # => (0+2i)
520
+ # -2.i # => (0-2i)
521
+ # 2.0.i # => (0+2.0i)
522
+ # Rational(1, 2).i # => (0+(1/2)*i)
523
+ # Complex(3, 4).i # Raises NoMethodError.
242
524
  #
243
525
  def i: () -> Complex
244
526
 
527
+ # <!-- rdoc-file=complex.c -->
245
528
  # Returns zero.
246
529
  #
247
530
  def imag: () -> Numeric
248
531
 
532
+ # <!--
533
+ # rdoc-file=complex.c
534
+ # - num.imag -> 0
535
+ # - num.imaginary -> 0
536
+ # -->
249
537
  # Returns zero.
250
538
  #
251
539
  def imaginary: () -> Numeric
252
540
 
541
+ # <!--
542
+ # rdoc-file=numeric.rb
543
+ # - num.infinite? -> -1, 1, or nil
544
+ # -->
253
545
  # Returns `nil`, -1, or 1 depending on whether the value is finite, `-Infinity`,
254
546
  # or `+Infinity`.
255
547
  #
256
548
  def infinite?: () -> Integer?
257
549
 
550
+ # <!--
551
+ # rdoc-file=numeric.rb
552
+ # - num.integer? -> true or false
553
+ # -->
258
554
  # Returns `true` if `num` is an Integer.
259
555
  #
260
556
  # 1.0.integer? #=> false
@@ -262,165 +558,347 @@ class Numeric
262
558
  #
263
559
  def integer?: () -> bool
264
560
 
265
- # Returns the absolute value of `num`.
561
+ # <!-- rdoc-file=numeric.c -->
562
+ # Returns the absolute value of `self`.
266
563
  #
267
- # 12.abs #=> 12
268
- # (-34.56).abs #=> 34.56
269
- # -34.56.abs #=> 34.56
564
+ # 12.abs #=> 12
565
+ # (-34.56).abs #=> 34.56
566
+ # -34.56.abs #=> 34.56
270
567
  #
271
568
  # Numeric#magnitude is an alias for Numeric#abs.
272
569
  #
273
570
  alias magnitude abs
274
571
 
275
- # `x.modulo(y)` means `x-y*(x/y).floor`.
572
+ # <!-- rdoc-file=numeric.c -->
573
+ # Returns `self` modulo `other` as a real number.
574
+ #
575
+ # Of the Core and Standard Library classes, only Rational uses this
576
+ # implementation.
276
577
  #
277
- # Equivalent to `num.divmod(numeric)[1]`.
578
+ # For Rational `r` and real number `n`, these expressions are equivalent:
579
+ #
580
+ # c % n
581
+ # c-n*(c/n).floor
582
+ # c.divmod(n)[1]
278
583
  #
279
584
  # See Numeric#divmod.
280
585
  #
586
+ # Examples:
587
+ #
588
+ # r = Rational(1, 2) # => (1/2)
589
+ # r2 = Rational(2, 3) # => (2/3)
590
+ # r % r2 # => (1/2)
591
+ # r % 2 # => (1/2)
592
+ # r % 2.0 # => 0.5
593
+ #
594
+ # r = Rational(301,100) # => (301/100)
595
+ # r2 = Rational(7,5) # => (7/5)
596
+ # r % r2 # => (21/100)
597
+ # r % -r2 # => (-119/100)
598
+ # (-r) % r2 # => (119/100)
599
+ # (-r) %-r2 # => (-21/100)
600
+ #
601
+ # Numeric#modulo is an alias for Numeric#%.
602
+ #
281
603
  def modulo: (Numeric) -> Numeric
282
604
 
283
- # Returns `true` if `num` is less than 0.
605
+ # <!--
606
+ # rdoc-file=numeric.c
607
+ # - negative? -> true or false
608
+ # -->
609
+ # Returns `true` if `self` is less than 0, `false` otherwise.
284
610
  #
285
611
  def negative?: () -> bool
286
612
 
287
- # Returns `self` if `num` is not zero, `nil` otherwise.
613
+ # <!--
614
+ # rdoc-file=numeric.c
615
+ # - nonzero? -> self or nil
616
+ # -->
617
+ # Returns `self` if `self` is not a zero value, `nil` otherwise; uses method
618
+ # `zero?` for the evaluation.
619
+ #
620
+ # The returned `self` allows the method to be chained:
288
621
  #
289
- # This behavior is useful when chaining comparisons:
622
+ # a = %w[z Bb bB bb BB a aA Aa AA A]
623
+ # a.sort {|a, b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
624
+ # # => ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
290
625
  #
291
- # a = %w( z Bb bB bb BB a aA Aa AA A )
292
- # b = a.sort {|a,b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
293
- # b #=> ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
626
+ # Of the Core and Standard Library classes, Integer, Float, Rational, and
627
+ # Complex use this implementation.
294
628
  #
295
629
  def nonzero?: () -> self?
296
630
 
631
+ # <!--
632
+ # rdoc-file=rational.c
633
+ # - num.numerator -> integer
634
+ # -->
297
635
  # Returns the numerator.
298
636
  #
299
637
  def numerator: () -> Numeric
300
638
 
639
+ # <!-- rdoc-file=complex.c -->
301
640
  # Returns 0 if the value is positive, pi otherwise.
302
641
  #
303
642
  alias phase angle
304
643
 
644
+ # <!--
645
+ # rdoc-file=complex.c
646
+ # - num.polar -> array
647
+ # -->
305
648
  # Returns an array; [num.abs, num.arg].
306
649
  #
307
650
  def polar: () -> [ Numeric, Numeric ]
308
651
 
309
- # Returns `true` if `num` is greater than 0.
652
+ # <!--
653
+ # rdoc-file=numeric.c
654
+ # - positive? -> true or false
655
+ # -->
656
+ # Returns `true` if `self` is greater than 0, `false` otherwise.
310
657
  #
311
658
  def positive?: () -> bool
312
659
 
660
+ # <!--
661
+ # rdoc-file=rational.c
662
+ # - num.quo(int_or_rat) -> rat
663
+ # - num.quo(flo) -> flo
664
+ # -->
313
665
  # Returns the most exact division (rational for integers, float for floats).
314
666
  #
315
667
  def quo: (Numeric) -> Numeric
316
668
 
669
+ # <!--
670
+ # rdoc-file=complex.c
671
+ # - num.real -> self
672
+ # -->
317
673
  # Returns self.
318
674
  #
319
675
  def real: () -> Numeric
320
676
 
677
+ # <!--
678
+ # rdoc-file=numeric.rb
679
+ # - num.real? -> true or false
680
+ # -->
321
681
  # Returns `true` if `num` is a real number (i.e. not Complex).
322
682
  #
323
683
  def real?: () -> bool
324
684
 
685
+ # <!-- rdoc-file=complex.c -->
325
686
  # Returns an array; [num, 0].
326
687
  #
327
688
  def rect: () -> [ Numeric, Numeric ]
328
689
 
690
+ # <!--
691
+ # rdoc-file=complex.c
692
+ # - num.rect -> array
693
+ # - num.rectangular -> array
694
+ # -->
329
695
  # Returns an array; [num, 0].
330
696
  #
331
697
  alias rectangular rect
332
698
 
333
- # `x.remainder(y)` means `x-y*(x/y).truncate`.
699
+ # <!--
700
+ # rdoc-file=numeric.c
701
+ # - remainder(other) -> real_number
702
+ # -->
703
+ # Returns the remainder after dividing `self` by `other`.
334
704
  #
335
- # See Numeric#divmod.
705
+ # Of the Core and Standard Library classes, only Float and Rational use this
706
+ # implementation.
707
+ #
708
+ # Examples:
709
+ #
710
+ # 11.0.remainder(4) # => 3.0
711
+ # 11.0.remainder(-4) # => 3.0
712
+ # -11.0.remainder(4) # => -3.0
713
+ # -11.0.remainder(-4) # => -3.0
714
+ #
715
+ # 12.0.remainder(4) # => 0.0
716
+ # 12.0.remainder(-4) # => 0.0
717
+ # -12.0.remainder(4) # => -0.0
718
+ # -12.0.remainder(-4) # => -0.0
719
+ #
720
+ # 13.0.remainder(4.0) # => 1.0
721
+ # 13.0.remainder(Rational(4, 1)) # => 1.0
722
+ #
723
+ # Rational(13, 1).remainder(4) # => (1/1)
724
+ # Rational(13, 1).remainder(-4) # => (1/1)
725
+ # Rational(-13, 1).remainder(4) # => (-1/1)
726
+ # Rational(-13, 1).remainder(-4) # => (-1/1)
336
727
  #
337
728
  def remainder: (Numeric) -> Numeric
338
729
 
339
- # Returns `num` rounded to the nearest value with a precision of `ndigits`
340
- # decimal digits (default: 0).
730
+ # <!--
731
+ # rdoc-file=numeric.c
732
+ # - round(digits = 0) -> integer or float
733
+ # -->
734
+ # Returns `self` rounded to the nearest value with a precision of `digits`
735
+ # decimal digits.
341
736
  #
342
- # Numeric implements this by converting its value to a Float and invoking
737
+ # Numeric implements this by converting `self` to a Float and invoking
343
738
  # Float#round.
344
739
  #
345
740
  def round: () -> Integer
346
741
  | (Integer digits) -> Numeric
347
742
 
348
- # Invokes the given block with the sequence of numbers starting at `num`,
349
- # incremented by `step` (defaulted to `1`) on each call.
350
- #
351
- # The loop finishes when the value to be passed to the block is greater than
352
- # `limit` (if `step` is positive) or less than `limit` (if `step` is negative),
353
- # where `limit` is defaulted to infinity.
354
- #
355
- # In the recommended keyword argument style, either or both of `step` and
356
- # `limit` (default infinity) can be omitted. In the fixed position argument
357
- # style, zero as a step (i.e. `num.step(limit, 0)`) is not allowed for
358
- # historical compatibility reasons.
359
- #
360
- # If all the arguments are integers, the loop operates using an integer counter.
361
- #
362
- # If any of the arguments are floating point numbers, all are converted to
363
- # floats, and the loop is executed *floor(n + n*Float::EPSILON) + 1* times,
364
- # where *n = (limit - num)/step*.
365
- #
366
- # Otherwise, the loop starts at `num`, uses either the less-than (`<`) or
367
- # greater-than (`>`) operator to compare the counter against `limit`, and
368
- # increments itself using the `+` operator.
369
- #
370
- # If no block is given, an Enumerator is returned instead. Especially, the
371
- # enumerator is an Enumerator::ArithmeticSequence if both `limit` and `step` are
372
- # kind of Numeric or `nil`.
373
- #
374
- # For example:
375
- #
376
- # p 1.step.take(4)
377
- # p 10.step(by: -1).take(4)
378
- # 3.step(to: 5) {|i| print i, " " }
379
- # 1.step(10, 2) {|i| print i, " " }
380
- # Math::E.step(to: Math::PI, by: 0.2) {|f| print f, " " }
381
- #
382
- # Will produce:
383
- #
384
- # [1, 2, 3, 4]
385
- # [10, 9, 8, 7]
386
- # 3 4 5
387
- # 1 3 5 7 9
388
- # 2.718281828459045 2.9182818284590453 3.118281828459045
743
+ # <!--
744
+ # rdoc-file=numeric.c
745
+ # - step(to = nil, by = 1) {|n| ... } -> self
746
+ # - step(to = nil, by = 1) -> enumerator
747
+ # - step(to = nil, by: 1) {|n| ... } -> self
748
+ # - step(to = nil, by: 1) -> enumerator
749
+ # - step(by: 1, to: ) {|n| ... } -> self
750
+ # - step(by: 1, to: ) -> enumerator
751
+ # - step(by: , to: nil) {|n| ... } -> self
752
+ # - step(by: , to: nil) -> enumerator
753
+ # -->
754
+ # Generates a sequence of numbers; with a block given, traverses the sequence.
755
+ #
756
+ # Of the Core and Standard Library classes,
757
+ # Integer, Float, and Rational use this implementation.
758
+ #
759
+ # A quick example:
760
+ #
761
+ # squares = []
762
+ # 1.step(by: 2, to: 10) {|i| squares.push(i*i) }
763
+ # squares # => [1, 9, 25, 49, 81]
764
+ #
765
+ # The generated sequence:
766
+ #
767
+ # - Begins with +self+.
768
+ # - Continues at intervals of +step+ (which may not be zero).
769
+ # - Ends with the last number that is within or equal to +limit+;
770
+ # that is, less than or equal to +limit+ if +step+ is positive,
771
+ # greater than or equal to +limit+ if +step+ is negative.
772
+ # If +limit+ is not given, the sequence is of infinite length.
773
+ #
774
+ # If a block is given, calls the block with each number in the sequence;
775
+ # returns +self+. If no block is given, returns an Enumerator::ArithmeticSequence.
776
+ #
777
+ # <b>Keyword Arguments</b>
778
+ #
779
+ # With keyword arguments +by+ and +to+,
780
+ # their values (or defaults) determine the step and limit:
781
+ #
782
+ # # Both keywords given.
783
+ # squares = []
784
+ # 4.step(by: 2, to: 10) {|i| squares.push(i*i) } # => 4
785
+ # squares # => [16, 36, 64, 100]
786
+ # cubes = []
787
+ # 3.step(by: -1.5, to: -3) {|i| cubes.push(i*i*i) } # => 3
788
+ # cubes # => [27.0, 3.375, 0.0, -3.375, -27.0]
789
+ # squares = []
790
+ # 1.2.step(by: 0.2, to: 2.0) {|f| squares.push(f*f) }
791
+ # squares # => [1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0]
792
+ #
793
+ # squares = []
794
+ # Rational(6/5).step(by: 0.2, to: 2.0) {|r| squares.push(r*r) }
795
+ # squares # => [1.0, 1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0]
796
+ #
797
+ # # Only keyword to given.
798
+ # squares = []
799
+ # 4.step(to: 10) {|i| squares.push(i*i) } # => 4
800
+ # squares # => [16, 25, 36, 49, 64, 81, 100]
801
+ # # Only by given.
802
+ #
803
+ # # Only keyword by given
804
+ # squares = []
805
+ # 4.step(by:2) {|i| squares.push(i*i); break if i > 10 }
806
+ # squares # => [16, 36, 64, 100, 144]
807
+ #
808
+ # # No block given.
809
+ # e = 3.step(by: -1.5, to: -3) # => (3.step(by: -1.5, to: -3))
810
+ # e.class # => Enumerator::ArithmeticSequence
811
+ #
812
+ # <b>Positional Arguments</b>
813
+ #
814
+ # With optional positional arguments +limit+ and +step+,
815
+ # their values (or defaults) determine the step and limit:
816
+ #
817
+ # squares = []
818
+ # 4.step(10, 2) {|i| squares.push(i*i) } # => 4
819
+ # squares # => [16, 36, 64, 100]
820
+ # squares = []
821
+ # 4.step(10) {|i| squares.push(i*i) }
822
+ # squares # => [16, 25, 36, 49, 64, 81, 100]
823
+ # squares = []
824
+ # 4.step {|i| squares.push(i*i); break if i > 10 } # => nil
825
+ # squares # => [16, 25, 36, 49, 64, 81, 100, 121]
826
+ #
827
+ # **Implementation Notes**
828
+ #
829
+ # If all the arguments are integers, the loop operates using an integer
830
+ # counter.
831
+ #
832
+ # If any of the arguments are floating point numbers, all are converted
833
+ # to floats, and the loop is executed
834
+ # <i>floor(n + n*Float::EPSILON) + 1</i> times,
835
+ # where <i>n = (limit - self)/step</i>.
389
836
  #
390
837
  def step: (?Numeric limit, ?Numeric step) { (Numeric) -> void } -> self
391
838
  | (?Numeric limit, ?Numeric step) -> Enumerator[Numeric, self]
392
839
  | (?by: Numeric, ?to: Numeric) { (Numeric) -> void } -> self
393
840
  | (?by: Numeric, ?to: Numeric) -> Enumerator[Numeric, self]
394
841
 
842
+ # <!--
843
+ # rdoc-file=complex.c
844
+ # - num.to_c -> complex
845
+ # -->
395
846
  # Returns the value as a complex.
396
847
  #
397
848
  def to_c: () -> Complex
398
849
 
399
- # Invokes the child class's `to_i` method to convert `num` to an integer.
850
+ # <!--
851
+ # rdoc-file=numeric.c
852
+ # - to_int -> integer
853
+ # -->
854
+ # Returns `self` as an integer; converts using method `to_i` in the derived
855
+ # class.
856
+ #
857
+ # Of the Core and Standard Library classes, only Rational and Complex use this
858
+ # implementation.
400
859
  #
401
- # 1.0.class #=> Float
402
- # 1.0.to_int.class #=> Integer
403
- # 1.0.to_i.class #=> Integer
860
+ # Examples:
861
+ #
862
+ # Rational(1, 2).to_int # => 0
863
+ # Rational(2, 1).to_int # => 2
864
+ # Complex(2, 0).to_int # => 2
865
+ # Complex(2, 1) # Raises RangeError (non-zero imaginary part)
404
866
  #
405
867
  def to_int: () -> Integer
406
868
 
407
- # Returns `num` truncated (toward zero) to a precision of `ndigits` decimal
408
- # digits (default: 0).
869
+ # <!--
870
+ # rdoc-file=numeric.c
871
+ # - truncate(digits = 0) -> integer or float
872
+ # -->
873
+ # Returns `self` truncated (toward zero) to a precision of `digits` decimal
874
+ # digits.
409
875
  #
410
- # Numeric implements this by converting its value to a Float and invoking
876
+ # Numeric implements this by converting `self` to a Float and invoking
411
877
  # Float#truncate.
412
878
  #
413
879
  def truncate: () -> Integer
414
880
  | (Integer ndigits) -> (Integer | Numeric)
415
881
 
416
- # Returns `true` if `num` has a zero value.
882
+ # <!--
883
+ # rdoc-file=numeric.c
884
+ # - zero? -> true or false
885
+ # -->
886
+ # Returns `true` if `zero` has a zero value, `false` otherwise.
887
+ #
888
+ # Of the Core and Standard Library classes, only Rational and Complex use this
889
+ # implementation.
417
890
  #
418
891
  def zero?: () -> bool
419
892
 
420
- # Returns +self+.
893
+ # <!--
894
+ # rdoc-file=numeric.c
895
+ # - clone(freeze: true) -> self
896
+ # -->
897
+ # Returns `self`.
421
898
  #
422
- # Raises an exception if the value for +freeze+ is neither +true+ nor +nil+.
899
+ # Raises an exception if the value for `freeze` is neither `true` nor `nil`.
423
900
  #
424
901
  # Related: Numeric#dup.
902
+ #
425
903
  def clone: (?freeze: true?) -> self
426
904
  end