rbs 4.0.0.dev.4 → 4.1.0.pre.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +1 -0
  3. data/.github/dependabot.yml +16 -14
  4. data/.github/workflows/bundle-update.yml +63 -0
  5. data/.github/workflows/c-check.yml +21 -11
  6. data/.github/workflows/comments.yml +5 -3
  7. data/.github/workflows/dependabot.yml +2 -2
  8. data/.github/workflows/jruby.yml +67 -0
  9. data/.github/workflows/milestone.yml +83 -0
  10. data/.github/workflows/ruby.yml +63 -24
  11. data/.github/workflows/rust.yml +184 -0
  12. data/.github/workflows/truffleruby.yml +54 -0
  13. data/.github/workflows/typecheck.yml +5 -2
  14. data/.github/workflows/wasm.yml +53 -0
  15. data/.github/workflows/windows.yml +8 -2
  16. data/.gitignore +11 -0
  17. data/.rubocop.yml +1 -1
  18. data/CHANGELOG.md +357 -0
  19. data/README.md +4 -4
  20. data/Rakefile +365 -33
  21. data/Steepfile +8 -0
  22. data/config.yml +450 -24
  23. data/core/array.rbs +443 -363
  24. data/core/basic_object.rbs +9 -8
  25. data/core/binding.rbs +0 -2
  26. data/core/builtin.rbs +9 -8
  27. data/core/class.rbs +11 -8
  28. data/core/comparable.rbs +55 -34
  29. data/core/complex.rbs +104 -78
  30. data/core/dir.rbs +61 -49
  31. data/core/encoding.rbs +12 -15
  32. data/core/enumerable.rbs +288 -196
  33. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  34. data/core/enumerator/product.rbs +5 -5
  35. data/core/enumerator.rbs +91 -28
  36. data/core/errno.rbs +11 -2
  37. data/core/errors.rbs +58 -29
  38. data/core/exception.rbs +13 -13
  39. data/core/fiber.rbs +74 -54
  40. data/core/file.rbs +260 -1151
  41. data/core/file_constants.rbs +463 -0
  42. data/core/file_stat.rbs +534 -0
  43. data/core/file_test.rbs +3 -3
  44. data/core/float.rbs +257 -92
  45. data/core/gc.rbs +425 -281
  46. data/core/hash.rbs +1151 -829
  47. data/core/integer.rbs +156 -195
  48. data/core/io/buffer.rbs +53 -42
  49. data/core/io/wait.rbs +13 -35
  50. data/core/io.rbs +216 -150
  51. data/core/kernel.rbs +239 -163
  52. data/core/marshal.rbs +4 -4
  53. data/core/match_data.rbs +15 -13
  54. data/core/math.rbs +107 -66
  55. data/core/method.rbs +69 -33
  56. data/core/module.rbs +302 -150
  57. data/core/nil_class.rbs +7 -6
  58. data/core/numeric.rbs +77 -63
  59. data/core/object.rbs +9 -11
  60. data/core/object_space/weak_key_map.rbs +7 -7
  61. data/core/object_space.rbs +30 -23
  62. data/core/pathname.rbs +1322 -0
  63. data/core/proc.rbs +95 -58
  64. data/core/process.rbs +222 -202
  65. data/core/ractor.rbs +371 -515
  66. data/core/random.rbs +21 -3
  67. data/core/range.rbs +181 -79
  68. data/core/rational.rbs +60 -89
  69. data/core/rbs/ops.rbs +154 -0
  70. data/core/rbs/unnamed/argf.rbs +63 -56
  71. data/core/rbs/unnamed/env_class.rbs +19 -14
  72. data/core/rbs/unnamed/main_class.rbs +123 -0
  73. data/core/rbs/unnamed/random.rbs +11 -118
  74. data/core/regexp.rbs +258 -214
  75. data/core/ruby.rbs +53 -0
  76. data/core/ruby_vm.rbs +78 -34
  77. data/core/rubygems/config_file.rbs +5 -5
  78. data/core/rubygems/errors.rbs +4 -71
  79. data/core/rubygems/requirement.rbs +5 -5
  80. data/core/rubygems/rubygems.rbs +16 -82
  81. data/core/rubygems/version.rbs +2 -3
  82. data/core/set.rbs +493 -363
  83. data/core/signal.rbs +26 -16
  84. data/core/string.rbs +3234 -1285
  85. data/core/struct.rbs +43 -42
  86. data/core/symbol.rbs +41 -34
  87. data/core/thread.rbs +141 -73
  88. data/core/time.rbs +81 -50
  89. data/core/trace_point.rbs +41 -35
  90. data/core/true_class.rbs +2 -2
  91. data/core/unbound_method.rbs +24 -16
  92. data/core/warning.rbs +7 -7
  93. data/docs/CONTRIBUTING.md +2 -1
  94. data/docs/aliases.md +79 -0
  95. data/docs/collection.md +3 -3
  96. data/docs/config.md +171 -0
  97. data/docs/encoding.md +56 -0
  98. data/docs/gem.md +0 -1
  99. data/docs/inline.md +634 -0
  100. data/docs/rbs_by_example.md +20 -20
  101. data/docs/rust.md +96 -0
  102. data/docs/sigs.md +3 -3
  103. data/docs/syntax.md +48 -18
  104. data/docs/type_fingerprint.md +21 -0
  105. data/docs/wasm_serialization.md +80 -0
  106. data/exe/rbs +1 -1
  107. data/ext/rbs_extension/ast_translation.c +1441 -671
  108. data/ext/rbs_extension/ast_translation.h +7 -0
  109. data/ext/rbs_extension/class_constants.c +18 -2
  110. data/ext/rbs_extension/class_constants.h +9 -0
  111. data/ext/rbs_extension/extconf.rb +6 -1
  112. data/ext/rbs_extension/legacy_location.c +33 -56
  113. data/ext/rbs_extension/legacy_location.h +37 -0
  114. data/ext/rbs_extension/main.c +183 -39
  115. data/include/rbs/ast.h +597 -297
  116. data/include/rbs/defines.h +40 -0
  117. data/include/rbs/lexer.h +31 -11
  118. data/include/rbs/location.h +25 -44
  119. data/include/rbs/parser.h +6 -6
  120. data/include/rbs/serialize.h +39 -0
  121. data/include/rbs/string.h +0 -2
  122. data/include/rbs/util/rbs_allocator.h +34 -13
  123. data/include/rbs/util/rbs_assert.h +12 -1
  124. data/include/rbs/util/rbs_constant_pool.h +0 -3
  125. data/include/rbs/util/rbs_encoding.h +2 -0
  126. data/include/rbs/util/rbs_unescape.h +2 -1
  127. data/include/rbs.h +8 -0
  128. data/lib/rbs/annotate/rdoc_annotator.rb +27 -31
  129. data/lib/rbs/ast/annotation.rb +1 -1
  130. data/lib/rbs/ast/comment.rb +1 -1
  131. data/lib/rbs/ast/declarations.rb +10 -10
  132. data/lib/rbs/ast/members.rb +14 -14
  133. data/lib/rbs/ast/ruby/annotations.rb +335 -3
  134. data/lib/rbs/ast/ruby/comment_block.rb +30 -4
  135. data/lib/rbs/ast/ruby/declarations.rb +209 -4
  136. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  137. data/lib/rbs/ast/ruby/helpers/location_helper.rb +1 -1
  138. data/lib/rbs/ast/ruby/members.rb +571 -22
  139. data/lib/rbs/ast/type_param.rb +24 -4
  140. data/lib/rbs/buffer.rb +66 -24
  141. data/lib/rbs/cli/diff.rb +16 -15
  142. data/lib/rbs/cli/validate.rb +38 -106
  143. data/lib/rbs/cli.rb +55 -24
  144. data/lib/rbs/collection/config/lockfile_generator.rb +28 -3
  145. data/lib/rbs/collection/sources/git.rb +7 -0
  146. data/lib/rbs/definition.rb +1 -1
  147. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  148. data/lib/rbs/definition_builder/method_builder.rb +32 -6
  149. data/lib/rbs/definition_builder.rb +147 -25
  150. data/lib/rbs/diff.rb +7 -1
  151. data/lib/rbs/environment.rb +235 -75
  152. data/lib/rbs/environment_loader.rb +0 -6
  153. data/lib/rbs/errors.rb +27 -18
  154. data/lib/rbs/inline_parser.rb +377 -15
  155. data/lib/rbs/location_aux.rb +1 -1
  156. data/lib/rbs/locator.rb +5 -1
  157. data/lib/rbs/method_type.rb +5 -3
  158. data/lib/rbs/namespace.rb +47 -11
  159. data/lib/rbs/parser_aux.rb +20 -7
  160. data/lib/rbs/prototype/helpers.rb +57 -0
  161. data/lib/rbs/prototype/rb.rb +3 -28
  162. data/lib/rbs/prototype/rbi.rb +3 -20
  163. data/lib/rbs/prototype/runtime.rb +10 -0
  164. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  165. data/lib/rbs/resolver/type_name_resolver.rb +120 -44
  166. data/lib/rbs/rewriter.rb +70 -0
  167. data/lib/rbs/subtractor.rb +3 -1
  168. data/lib/rbs/test/type_check.rb +25 -3
  169. data/lib/rbs/type_name.rb +34 -14
  170. data/lib/rbs/types.rb +88 -78
  171. data/lib/rbs/unit_test/type_assertions.rb +44 -8
  172. data/lib/rbs/validator.rb +2 -2
  173. data/lib/rbs/version.rb +1 -1
  174. data/lib/rbs/wasm/deserializer.rb +213 -0
  175. data/lib/rbs/wasm/location.rb +61 -0
  176. data/lib/rbs/wasm/parser.rb +137 -0
  177. data/lib/rbs/wasm/runtime.rb +217 -0
  178. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  179. data/lib/rbs.rb +13 -2
  180. data/lib/rdoc/discover.rb +1 -1
  181. data/lib/rdoc_plugin/parser.rb +1 -1
  182. data/rbs.gemspec +24 -6
  183. data/schema/typeParam.json +17 -1
  184. data/sig/annotate/rdoc_annotater.rbs +12 -9
  185. data/sig/ast/ruby/annotations.rbs +364 -4
  186. data/sig/ast/ruby/comment_block.rbs +8 -0
  187. data/sig/ast/ruby/declarations.rbs +102 -4
  188. data/sig/ast/ruby/members.rbs +128 -2
  189. data/sig/buffer.rbs +19 -1
  190. data/sig/cli/diff.rbs +5 -11
  191. data/sig/cli/validate.rbs +12 -8
  192. data/sig/cli.rbs +18 -18
  193. data/sig/collection/config/lockfile_generator.rbs +2 -0
  194. data/sig/definition.rbs +6 -1
  195. data/sig/definition_builder.rbs +2 -0
  196. data/sig/environment.rbs +70 -12
  197. data/sig/errors.rbs +13 -14
  198. data/sig/inline_parser.rbs +41 -2
  199. data/sig/locator.rbs +0 -2
  200. data/sig/manifest.yaml +0 -2
  201. data/sig/method_builder.rbs +3 -1
  202. data/sig/namespace.rbs +20 -0
  203. data/sig/parser.rbs +41 -13
  204. data/sig/prototype/helpers.rbs +2 -0
  205. data/sig/resolver/type_name_resolver.rbs +36 -10
  206. data/sig/rewriter.rbs +45 -0
  207. data/sig/source.rbs +3 -3
  208. data/sig/type_param.rbs +13 -8
  209. data/sig/typename.rbs +15 -0
  210. data/sig/types.rbs +6 -7
  211. data/sig/unit_test/spy.rbs +0 -8
  212. data/sig/unit_test/type_assertions.rbs +15 -0
  213. data/sig/wasm/deserializer.rbs +66 -0
  214. data/sig/wasm/serialization_schema.rbs +13 -0
  215. data/src/ast.c +443 -162
  216. data/src/lexer.c +1415 -1313
  217. data/src/lexer.re +4 -0
  218. data/src/lexstate.c +63 -37
  219. data/src/location.c +7 -47
  220. data/src/parser.c +1032 -521
  221. data/src/serialize.c +958 -0
  222. data/src/string.c +0 -48
  223. data/src/util/rbs_allocator.c +89 -74
  224. data/src/util/rbs_assert.c +1 -1
  225. data/src/util/rbs_buffer.c +2 -2
  226. data/src/util/rbs_constant_pool.c +10 -14
  227. data/src/util/rbs_encoding.c +4 -8
  228. data/src/util/rbs_unescape.c +56 -20
  229. data/stdlib/abbrev/0/array.rbs +1 -1
  230. data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
  231. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  232. data/stdlib/cgi/0/core.rbs +9 -393
  233. data/stdlib/cgi/0/manifest.yaml +1 -0
  234. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  235. data/stdlib/coverage/0/coverage.rbs +7 -4
  236. data/stdlib/csv/0/csv.rbs +5 -5
  237. data/stdlib/date/0/date.rbs +92 -79
  238. data/stdlib/date/0/date_time.rbs +25 -24
  239. data/stdlib/delegate/0/delegator.rbs +10 -7
  240. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  241. data/stdlib/digest/0/digest.rbs +111 -1
  242. data/stdlib/erb/0/erb.rbs +748 -347
  243. data/stdlib/etc/0/etc.rbs +73 -54
  244. data/stdlib/fileutils/0/fileutils.rbs +179 -160
  245. data/stdlib/forwardable/0/forwardable.rbs +13 -10
  246. data/stdlib/io-console/0/io-console.rbs +2 -2
  247. data/stdlib/json/0/json.rbs +223 -142
  248. data/stdlib/monitor/0/monitor.rbs +3 -3
  249. data/stdlib/net-http/0/net-http.rbs +162 -134
  250. data/stdlib/objspace/0/objspace.rbs +17 -34
  251. data/stdlib/open-uri/0/open-uri.rbs +48 -8
  252. data/stdlib/open3/0/open3.rbs +469 -10
  253. data/stdlib/openssl/0/openssl.rbs +482 -364
  254. data/stdlib/optparse/0/optparse.rbs +26 -17
  255. data/stdlib/pathname/0/pathname.rbs +11 -1381
  256. data/stdlib/pp/0/pp.rbs +9 -8
  257. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  258. data/stdlib/pstore/0/pstore.rbs +35 -30
  259. data/stdlib/psych/0/psych.rbs +65 -12
  260. data/stdlib/psych/0/store.rbs +2 -4
  261. data/stdlib/pty/0/pty.rbs +9 -6
  262. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  263. data/stdlib/rdoc/0/code_object.rbs +2 -1
  264. data/stdlib/rdoc/0/parser.rbs +1 -1
  265. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  266. data/stdlib/rdoc/0/store.rbs +1 -1
  267. data/stdlib/resolv/0/resolv.rbs +26 -69
  268. data/stdlib/ripper/0/ripper.rbs +22 -19
  269. data/stdlib/securerandom/0/manifest.yaml +2 -0
  270. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  271. data/stdlib/shellwords/0/shellwords.rbs +3 -3
  272. data/stdlib/singleton/0/singleton.rbs +3 -0
  273. data/stdlib/socket/0/addrinfo.rbs +7 -7
  274. data/stdlib/socket/0/basic_socket.rbs +3 -3
  275. data/stdlib/socket/0/ip_socket.rbs +10 -8
  276. data/stdlib/socket/0/socket.rbs +23 -10
  277. data/stdlib/socket/0/tcp_server.rbs +1 -1
  278. data/stdlib/socket/0/tcp_socket.rbs +11 -3
  279. data/stdlib/socket/0/udp_socket.rbs +1 -1
  280. data/stdlib/socket/0/unix_server.rbs +1 -1
  281. data/stdlib/stringio/0/stringio.rbs +1209 -95
  282. data/stdlib/strscan/0/string_scanner.rbs +101 -80
  283. data/stdlib/tempfile/0/tempfile.rbs +25 -21
  284. data/stdlib/time/0/time.rbs +8 -6
  285. data/stdlib/timeout/0/timeout.rbs +63 -7
  286. data/stdlib/tsort/0/cyclic.rbs +4 -1
  287. data/stdlib/tsort/0/interfaces.rbs +8 -8
  288. data/stdlib/tsort/0/tsort.rbs +16 -15
  289. data/stdlib/uri/0/common.rbs +42 -20
  290. data/stdlib/uri/0/file.rbs +3 -3
  291. data/stdlib/uri/0/generic.rbs +26 -18
  292. data/stdlib/uri/0/http.rbs +2 -2
  293. data/stdlib/uri/0/ldap.rbs +2 -2
  294. data/stdlib/uri/0/mailto.rbs +3 -3
  295. data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
  296. data/stdlib/zlib/0/deflate.rbs +4 -3
  297. data/stdlib/zlib/0/gzip_reader.rbs +8 -8
  298. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  299. data/stdlib/zlib/0/inflate.rbs +1 -1
  300. data/stdlib/zlib/0/need_dict.rbs +1 -1
  301. data/stdlib/zlib/0/zstream.rbs +1 -0
  302. data/wasm/README.md +59 -0
  303. data/wasm/rbs_wasm.c +411 -0
  304. metadata +56 -8
  305. data/.vscode/extensions.json +0 -5
  306. data/.vscode/settings.json +0 -19
data/core/integer.rbs CHANGED
@@ -88,11 +88,13 @@
88
88
  # * #downto: Calls the given block with each integer value from `self` down to
89
89
  # the given value.
90
90
  # * #times: Calls the given block `self` times with each integer in
91
- # `(0..self-1)`.
91
+ # <code>(0..self-1)</code>.
92
92
  # * #upto: Calls the given block with each integer value from `self` up to the
93
93
  # given value.
94
94
  #
95
95
  class Integer < Numeric
96
+ # TODO: `undef self.new`
97
+
96
98
  # <!--
97
99
  # rdoc-file=numeric.c
98
100
  # - Integer.sqrt(numeric) -> integer
@@ -114,9 +116,9 @@ class Integer < Numeric
114
116
  # Integer.sqrt(4.0) # => 2
115
117
  # Integer.sqrt(3.14159) # => 1
116
118
  #
117
- # This method is equivalent to `Math.sqrt(numeric).floor`, except that the
118
- # result of the latter code may differ from the true value due to the limited
119
- # precision of floating point arithmetic.
119
+ # This method is equivalent to <code>Math.sqrt(numeric).floor</code>, except
120
+ # that the result of the latter code may differ from the true value due to the
121
+ # limited precision of floating point arithmetic.
120
122
  #
121
123
  # Integer.sqrt(10**46) # => 100000000000000000000000
122
124
  # Math.sqrt(10**46).floor # => 99999999999999991611392
@@ -132,23 +134,24 @@ class Integer < Numeric
132
134
  # If `object` is an Integer object, returns `object`.
133
135
  # Integer.try_convert(1) # => 1
134
136
  #
135
- # Otherwise if `object` responds to `:to_int`, calls `object.to_int` and returns
136
- # the result.
137
+ # Otherwise if `object` responds to <code>:to_int</code>, calls
138
+ # <code>object.to_int</code> and returns the result.
137
139
  # Integer.try_convert(1.25) # => 1
138
140
  #
139
- # Returns `nil` if `object` does not respond to `:to_int`
141
+ # Returns `nil` if `object` does not respond to <code>:to_int</code>
140
142
  # Integer.try_convert([]) # => nil
141
143
  #
142
- # Raises an exception unless `object.to_int` returns an Integer object.
144
+ # Raises an exception unless <code>object.to_int</code> returns an Integer
145
+ # object.
143
146
  #
144
147
  def self.try_convert: (int) -> Integer
145
148
  | (untyped) -> Integer?
146
149
 
147
150
  # <!--
148
151
  # rdoc-file=numeric.c
149
- # - self % other -> real_number
152
+ # - self % other -> real_numeric
150
153
  # -->
151
- # Returns `self` modulo `other` as a real number.
154
+ # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
152
155
  #
153
156
  # For integer `n` and real number `r`, these expressions are equivalent:
154
157
  #
@@ -193,13 +196,13 @@ class Integer < Numeric
193
196
 
194
197
  # <!--
195
198
  # rdoc-file=numeric.c
196
- # - self * numeric -> numeric_result
199
+ # - self * other -> numeric
197
200
  # -->
198
- # Performs multiplication:
201
+ # Returns the numeric product of `self` and `other`:
199
202
  #
200
203
  # 4 * 2 # => 8
201
- # 4 * -2 # => -8
202
204
  # -4 * 2 # => -8
205
+ # 4 * -2 # => -8
203
206
  # 4 * 2.0 # => 8.0
204
207
  # 4 * Rational(1, 3) # => (4/3)
205
208
  # 4 * Complex(2, 0) # => (8+0i)
@@ -211,17 +214,47 @@ class Integer < Numeric
211
214
 
212
215
  # <!--
213
216
  # rdoc-file=numeric.c
214
- # - self ** numeric -> numeric_result
217
+ # - self ** exponent -> numeric
215
218
  # -->
216
- # Raises `self` to the power of `numeric`:
217
- #
218
- # 2 ** 3 # => 8
219
- # 2 ** -3 # => (1/8)
220
- # -2 ** 3 # => -8
221
- # -2 ** -3 # => (-1/8)
222
- # 2 ** 3.3 # => 9.849155306759329
223
- # 2 ** Rational(3, 1) # => (8/1)
224
- # 2 ** Complex(3, 0) # => (8+0i)
219
+ # Returns `self` raised to the power `exponent`:
220
+ #
221
+ # # Result for non-negative Integer exponent is Integer.
222
+ # 2 ** 0 # => 1
223
+ # 2 ** 1 # => 2
224
+ # 2 ** 2 # => 4
225
+ # 2 ** 3 # => 8
226
+ # -2 ** 3 # => -8
227
+ # # Result for negative Integer exponent is Rational, not Float.
228
+ # 2 ** -3 # => (1/8)
229
+ # -2 ** -3 # => (-1/8)
230
+ #
231
+ # # Result for Float exponent is Float.
232
+ # 2 ** 0.0 # => 1.0
233
+ # 2 ** 1.0 # => 2.0
234
+ # 2 ** 2.0 # => 4.0
235
+ # 2 ** 3.0 # => 8.0
236
+ # -2 ** 3.0 # => -8.0
237
+ # 2 ** -3.0 # => 0.125
238
+ # -2 ** -3.0 # => -0.125
239
+ #
240
+ # # Result for non-negative Complex exponent is Complex with Integer parts.
241
+ # 2 ** Complex(0, 0) # => (1+0i)
242
+ # 2 ** Complex(1, 0) # => (2+0i)
243
+ # 2 ** Complex(2, 0) # => (4+0i)
244
+ # 2 ** Complex(3, 0) # => (8+0i)
245
+ # -2 ** Complex(3, 0) # => (-8+0i)
246
+ # # Result for negative Complex exponent is Complex with Rational parts.
247
+ # 2 ** Complex(-3, 0) # => ((1/8)+(0/1)*i)
248
+ # -2 ** Complex(-3, 0) # => ((-1/8)+(0/1)*i)
249
+ #
250
+ # # Result for Rational exponent is Rational.
251
+ # 2 ** Rational(0, 1) # => (1/1)
252
+ # 2 ** Rational(1, 1) # => (2/1)
253
+ # 2 ** Rational(2, 1) # => (4/1)
254
+ # 2 ** Rational(3, 1) # => (8/1)
255
+ # -2 ** Rational(3, 1) # => (-8/1)
256
+ # 2 ** Rational(-3, 1) # => (1/8)
257
+ # -2 ** Rational(-3, 1) # => (-1/8)
225
258
  #
226
259
  def **: (Integer) -> Numeric
227
260
  | (Float) -> Numeric
@@ -230,29 +263,31 @@ class Integer < Numeric
230
263
 
231
264
  # <!--
232
265
  # rdoc-file=numeric.c
233
- # - self + numeric -> numeric_result
266
+ # - self + other -> numeric
234
267
  # -->
235
- # Performs addition:
268
+ # Returns the sum of `self` and `other`:
269
+ #
270
+ # 1 + 1 # => 2
271
+ # 1 + -1 # => 0
272
+ # 1 + 0 # => 1
273
+ # 1 + -2 # => -1
274
+ # 1 + Complex(1, 0) # => (2+0i)
275
+ # 1 + Rational(1, 1) # => (2/1)
236
276
  #
237
- # 2 + 2 # => 4
238
- # -2 + 2 # => 0
239
- # -2 + -2 # => -4
240
- # 2 + 2.0 # => 4.0
241
- # 2 + Rational(2, 1) # => (4/1)
242
- # 2 + Complex(2, 0) # => (4+0i)
277
+ # For a computation involving Floats, the result may be inexact (see Float#+):
278
+ #
279
+ # 1 + 3.14 # => 4.140000000000001
243
280
  #
244
281
  def +: (Integer) -> Integer
245
282
  | (Float) -> Float
246
283
  | (Rational) -> Rational
247
284
  | (Complex) -> Complex
248
285
 
249
- def +@: () -> Integer
250
-
251
286
  # <!--
252
287
  # rdoc-file=numeric.c
253
- # - self - numeric -> numeric_result
288
+ # - self - other -> numeric
254
289
  # -->
255
- # Performs subtraction:
290
+ # Returns the difference of `self` and `other`:
256
291
  #
257
292
  # 4 - 2 # => 2
258
293
  # -4 - 2 # => -6
@@ -268,28 +303,34 @@ class Integer < Numeric
268
303
 
269
304
  # <!--
270
305
  # rdoc-file=numeric.rb
271
- # - -int -> integer
306
+ # - -self -> integer
272
307
  # -->
273
- # Returns `self`, negated.
308
+ # Returns `self`, negated:
309
+ #
310
+ # -1 # => -1
311
+ # -(-1) # => 1
312
+ # -0 # => 0
274
313
  #
275
314
  def -@: () -> Integer
276
315
 
277
316
  # <!--
278
317
  # rdoc-file=numeric.c
279
- # - self / numeric -> numeric_result
318
+ # - self / other -> numeric
280
319
  # -->
281
- # Performs division; for integer `numeric`, truncates the result to an integer:
320
+ # Returns the quotient of `self` and `other`.
282
321
  #
283
- # 4 / 3 # => 1
284
- # 4 / -3 # => -2
285
- # -4 / 3 # => -2
286
- # -4 / -3 # => 1
322
+ # For integer `other`, truncates the result to an integer:
287
323
  #
288
- # For other +numeric+, returns non-integer result:
324
+ # 4 / 3 # => 1
325
+ # 4 / -3 # => -2
326
+ # -4 / 3 # => -2
327
+ # -4 / -3 # => 1
289
328
  #
290
- # 4 / 3.0 # => 1.3333333333333333
291
- # 4 / Rational(3, 1) # => (4/3)
292
- # 4 / Complex(3, 0) # => ((4/3)+0i)
329
+ # For non-integer `other`, returns a non-integer result:
330
+ #
331
+ # 4 / 3.0 # => 1.3333333333333333
332
+ # 4 / Rational(3, 1) # => (4/3)
333
+ # 4 / Complex(3, 0) # => ((4/3)+0i)
293
334
  #
294
335
  def /: (Integer) -> Integer
295
336
  | (Float) -> Float
@@ -300,15 +341,14 @@ class Integer < Numeric
300
341
  # rdoc-file=numeric.c
301
342
  # - self < other -> true or false
302
343
  # -->
303
- # Returns `true` if the value of `self` is less than that of `other`:
344
+ # Returns whether the value of `self` is less than the value of `other`; `other`
345
+ # must be numeric, but may not be Complex:
304
346
  #
305
- # 1 < 0 # => false
306
- # 1 < 1 # => false
307
- # 1 < 2 # => true
308
- # 1 < 0.5 # => false
309
- # 1 < Rational(1, 2) # => false
310
- #
311
- # Raises an exception if the comparison cannot be made.
347
+ # 1 < 0 # => false
348
+ # 1 < 1 # => false
349
+ # 1 < 2 # => true
350
+ # 1 < 0.5 # => false
351
+ # 1 < Rational(1, 2) # => false
312
352
  #
313
353
  def <: (Numeric) -> bool
314
354
 
@@ -331,44 +371,46 @@ class Integer < Numeric
331
371
 
332
372
  # <!--
333
373
  # rdoc-file=numeric.c
334
- # - self <= real -> true or false
374
+ # - self <= other -> true or false
335
375
  # -->
336
- # Returns `true` if the value of `self` is less than or equal to that of
337
- # `other`:
376
+ # Returns whether the value of `self` is less than or equal to the value of
377
+ # `other`; `other` must be numeric, but may not be Complex:
338
378
  #
339
- # 1 <= 0 # => false
340
- # 1 <= 1 # => true
341
- # 1 <= 2 # => true
342
- # 1 <= 0.5 # => false
343
- # 1 <= Rational(1, 2) # => false
379
+ # 1 <= 0 # => false
380
+ # 1 <= 1 # => true
381
+ # 1 <= 2 # => true
382
+ # 1 <= 0.5 # => false
383
+ # 1 <= Rational(1, 2) # => false
344
384
  #
345
- # Raises an exception if the comparison cannot be made.
385
+ # Raises an exception if the comparison cannot be made.
346
386
  #
347
387
  def <=: (Numeric) -> bool
348
388
 
349
389
  # <!--
350
390
  # rdoc-file=numeric.c
351
- # - self <=> other -> -1, 0, +1, or nil
391
+ # - self <=> other -> -1, 0, 1, or nil
352
392
  # -->
393
+ # Compares `self` and `other`.
394
+ #
353
395
  # Returns:
354
396
  #
355
- # * -1, if `self` is less than `other`.
356
- # * 0, if `self` is equal to `other`.
357
- # * 1, if `self` is greater then `other`.
397
+ # * <code>-1</code>, if `self` is less than `other`.
398
+ # * `0`, if `self` is equal to `other`.
399
+ # * `1`, if `self` is greater then `other`.
358
400
  # * `nil`, if `self` and `other` are incomparable.
359
401
  #
360
402
  # Examples:
361
403
  #
362
404
  # 1 <=> 2 # => -1
363
405
  # 1 <=> 1 # => 0
364
- # 1 <=> 0 # => 1
365
- # 1 <=> 'foo' # => nil
366
- #
367
406
  # 1 <=> 1.0 # => 0
368
407
  # 1 <=> Rational(1, 1) # => 0
369
408
  # 1 <=> Complex(1, 0) # => 0
409
+ # 1 <=> 0 # => 1
410
+ # 1 <=> 'foo' # => nil
370
411
  #
371
- # This method is the basis for comparisons in module Comparable.
412
+ # Class Integer includes module Comparable, each of whose methods uses
413
+ # Integer#<=> for comparison.
372
414
  #
373
415
  def <=>: (Integer | Rational) -> Integer
374
416
  | (untyped) -> Integer?
@@ -381,7 +423,7 @@ class Integer < Numeric
381
423
  #
382
424
  # Related: Integer#eql? (requires `other` to be an Integer).
383
425
  #
384
- def ==: (untyped) -> bool
426
+ def ==: (untyped other) -> bool
385
427
 
386
428
  # <!--
387
429
  # rdoc-file=numeric.c
@@ -394,7 +436,7 @@ class Integer < Numeric
394
436
  #
395
437
  # Related: Integer#eql? (requires `other` to be an Integer).
396
438
  #
397
- def ===: (untyped) -> bool
439
+ alias === ==
398
440
 
399
441
  # <!--
400
442
  # rdoc-file=numeric.c
@@ -463,8 +505,8 @@ class Integer < Numeric
463
505
  # n[2] # => 0
464
506
  # n[3] # => 0
465
507
  #
466
- # In principle, `n[i]` is equivalent to `(n >> i) & 1`. Thus, negative index
467
- # always returns zero:
508
+ # In principle, <code>n[i]</code> is equivalent to <code>(n >> i) & 1</code>.
509
+ # Thus, negative index always returns zero:
468
510
  #
469
511
  # 255[-1] # => 0
470
512
  #
@@ -475,8 +517,9 @@ class Integer < Numeric
475
517
  # "%010b" % n[0, 10] # => "0000111000"
476
518
  # "%010b" % n[4, 10] # => "0000000011"
477
519
  #
478
- # With argument `range`, returns `range.size` bits from `self`, beginning at
479
- # `range.begin` and including bits of greater significance:
520
+ # With argument `range`, returns <code>range.size</code> bits from `self`,
521
+ # beginning at <code>range.begin</code> and including bits of greater
522
+ # significance:
480
523
  #
481
524
  # n = 0b111000 # => 56
482
525
  # "%010b" % n[0..9] # => "0000111000"
@@ -515,8 +558,6 @@ class Integer < Numeric
515
558
  #
516
559
  def abs: () -> Integer
517
560
 
518
- def abs2: () -> Integer
519
-
520
561
  # <!--
521
562
  # rdoc-file=numeric.c
522
563
  # - allbits?(mask) -> true or false
@@ -540,8 +581,6 @@ class Integer < Numeric
540
581
  #
541
582
  def allbits?: (int mask) -> bool
542
583
 
543
- def angle: () -> (Integer | Float)
544
-
545
584
  # <!--
546
585
  # rdoc-file=numeric.c
547
586
  # - anybits?(mask) -> true or false
@@ -576,7 +615,7 @@ class Integer < Numeric
576
615
  # significant bit has bit position 1). If there is no such bit (zero or minus
577
616
  # one), returns zero.
578
617
  #
579
- # This method returns `ceil(log2(self < 0 ? -self : self + 1))`>.
618
+ # This method returns <code>ceil(log2(self < 0 ? -self : self + 1))</code>>.
580
619
  #
581
620
  # (-2**1000-1).bit_length # => 1001
582
621
  # (-2**1000).bit_length # => 1000
@@ -629,7 +668,7 @@ class Integer < Numeric
629
668
  #
630
669
  # * When `self` is non-zero and `ndigits` is negative,
631
670
  # returns a value based on a computed granularity:
632
- # * The granularity is `10 ** ndigits.abs`.
671
+ # * The granularity is <code>10 ** ndigits.abs</code>.
633
672
  # * The returned value is the smallest multiple of the granularity
634
673
  # that is greater than or equal to `self`.
635
674
  # Examples with positive `self`:
@@ -650,8 +689,7 @@ class Integer < Numeric
650
689
  # -5| 100000| 0
651
690
  # Related: Integer#floor.
652
691
  #
653
- def ceil: () -> Integer
654
- | (int digits) -> (Integer | Float)
692
+ def ceil: (?int digits) -> Integer
655
693
 
656
694
  # <!--
657
695
  # rdoc-file=numeric.rb
@@ -689,7 +727,7 @@ class Integer < Numeric
689
727
  #
690
728
  # Related: Integer#ord.
691
729
  #
692
- def chr: (?encoding) -> String
730
+ def chr: (?encoding encoding) -> String
693
731
 
694
732
  # <!--
695
733
  # rdoc-file=bignum.c
@@ -706,17 +744,13 @@ class Integer < Numeric
706
744
  #
707
745
  def coerce: (Numeric) -> [ Numeric, Numeric ]
708
746
 
709
- def conj: () -> Integer
710
-
711
- def conjugate: () -> Integer
712
-
713
747
  # <!--
714
748
  # rdoc-file=numeric.rb
715
749
  # - denominator -> 1
716
750
  # -->
717
751
  # Returns `1`.
718
752
  #
719
- def denominator: () -> Integer
753
+ def denominator: () -> 1
720
754
 
721
755
  # <!--
722
756
  # rdoc-file=numeric.c
@@ -731,7 +765,7 @@ class Integer < Numeric
731
765
  #
732
766
  # Raises an exception if `self` is negative or `base` is less than 2.
733
767
  #
734
- def digits: (?int base) -> ::Array[Integer]
768
+ def digits: (?int base) -> Array[Integer]
735
769
 
736
770
  # <!--
737
771
  # rdoc-file=numeric.c
@@ -755,7 +789,7 @@ class Integer < Numeric
755
789
  # rdoc-file=numeric.c
756
790
  # - divmod(other) -> array
757
791
  # -->
758
- # Returns a 2-element array `[q, r]`, where
792
+ # Returns a 2-element array <code>[q, r]</code>, where
759
793
  #
760
794
  # q = (self/other).floor # Quotient
761
795
  # r = self % other # Remainder
@@ -801,10 +835,6 @@ class Integer < Numeric
801
835
  def downto: (Numeric limit) { (Integer) -> void } -> Integer
802
836
  | (Numeric limit) -> ::Enumerator[Integer, self]
803
837
 
804
- def dup: () -> self
805
-
806
- def eql?: (untyped) -> bool
807
-
808
838
  # <!--
809
839
  # rdoc-file=numeric.rb
810
840
  # - even? -> true or false
@@ -829,8 +859,6 @@ class Integer < Numeric
829
859
  #
830
860
  def fdiv: (Numeric) -> Float
831
861
 
832
- def finite?: () -> bool
833
-
834
862
  # <!--
835
863
  # rdoc-file=numeric.c
836
864
  # - floor(ndigits = 0) -> integer
@@ -850,7 +878,7 @@ class Integer < Numeric
850
878
  #
851
879
  # * When `self` is non-zero and `ndigits` is negative,
852
880
  # returns a value based on a computed granularity:
853
- # * The granularity is `10 ** ndigits.abs`.
881
+ # * The granularity is <code>10 ** ndigits.abs</code>.
854
882
  # * The returned value is the largest multiple of the granularity
855
883
  # that is less than or equal to `self`.
856
884
  # Examples with positive `self`:
@@ -885,7 +913,7 @@ class Integer < Numeric
885
913
  # 3.gcd(-7) #=> 1
886
914
  # ((1<<31)-1).gcd((1<<61)-1) #=> 1
887
915
  #
888
- def gcd: (Integer) -> Integer
916
+ def gcd: (Integer other_int) -> Integer
889
917
 
890
918
  # <!--
891
919
  # rdoc-file=rational.c
@@ -899,15 +927,7 @@ class Integer < Numeric
899
927
  # 3.gcdlcm(-7) #=> [1, 21]
900
928
  # ((1<<31)-1).gcdlcm((1<<61)-1) #=> [1, 4951760154835678088235319297]
901
929
  #
902
- def gcdlcm: (Integer) -> [ Integer, Integer ]
903
-
904
- def i: () -> Complex
905
-
906
- def imag: () -> Integer
907
-
908
- def imaginary: () -> Integer
909
-
910
- def infinite?: () -> Integer?
930
+ def gcdlcm: (Integer other_int) -> [ Integer, Integer ]
911
931
 
912
932
  # <!-- rdoc-file=numeric.c -->
913
933
  # Returns a string containing the place-value representation of `self` in radix
@@ -945,17 +965,17 @@ class Integer < Numeric
945
965
  # 3.lcm(-7) #=> 21
946
966
  # ((1<<31)-1).lcm((1<<61)-1) #=> 4951760154835678088235319297
947
967
  #
948
- def lcm: (Integer) -> Integer
968
+ def lcm: (Integer other_int) -> Integer
949
969
 
950
970
  # <!--
951
971
  # rdoc-file=numeric.rb
952
972
  # - magnitude()
953
973
  # -->
954
974
  #
955
- def magnitude: () -> Integer
975
+ alias magnitude abs
956
976
 
957
977
  # <!-- rdoc-file=numeric.c -->
958
- # Returns `self` modulo `other` as a real number.
978
+ # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
959
979
  #
960
980
  # For integer `n` and real number `r`, these expressions are equivalent:
961
981
  #
@@ -983,14 +1003,14 @@ class Integer < Numeric
983
1003
  def negative?: () -> bool
984
1004
 
985
1005
  # <!-- rdoc-file=numeric.c -->
986
- # Returns the successor integer of `self` (equivalent to `self + 1`):
1006
+ # Returns the successor integer of `self` (equivalent to <code>self + 1</code>):
987
1007
  #
988
1008
  # 1.succ #=> 2
989
1009
  # -1.succ #=> 0
990
1010
  #
991
1011
  # Related: Integer#pred (predecessor value).
992
1012
  #
993
- def next: () -> Integer
1013
+ alias next succ
994
1014
 
995
1015
  # <!--
996
1016
  # rdoc-file=numeric.c
@@ -1015,15 +1035,13 @@ class Integer < Numeric
1015
1035
  #
1016
1036
  def nobits?: (int mask) -> bool
1017
1037
 
1018
- def nonzero?: () -> self?
1019
-
1020
1038
  # <!--
1021
1039
  # rdoc-file=numeric.rb
1022
1040
  # - numerator -> self
1023
1041
  # -->
1024
1042
  # Returns `self`.
1025
1043
  #
1026
- def numerator: () -> Integer
1044
+ def numerator: () -> self
1027
1045
 
1028
1046
  # <!--
1029
1047
  # rdoc-file=numeric.rb
@@ -1039,9 +1057,7 @@ class Integer < Numeric
1039
1057
  # -->
1040
1058
  # Returns `self`; intended for compatibility to character literals in Ruby 1.9.
1041
1059
  #
1042
- def ord: () -> Integer
1043
-
1044
- alias phase angle
1060
+ def ord: () -> self
1045
1061
 
1046
1062
  def polar: () -> [ Integer, Integer | Float ]
1047
1063
 
@@ -1067,7 +1083,7 @@ class Integer < Numeric
1067
1083
  # rdoc-file=numeric.c
1068
1084
  # - pred -> next_integer
1069
1085
  # -->
1070
- # Returns the predecessor of `self` (equivalent to `self - 1`):
1086
+ # Returns the predecessor of `self` (equivalent to <code>self - 1</code>):
1071
1087
  #
1072
1088
  # 1.pred #=> 0
1073
1089
  # -1.pred #=> -2
@@ -1091,14 +1107,8 @@ class Integer < Numeric
1091
1107
  #
1092
1108
  def rationalize: (?Numeric eps) -> Rational
1093
1109
 
1094
- def real: () -> self
1095
-
1096
- def real?: () -> true
1097
-
1098
1110
  def rect: () -> [ Integer, Numeric ]
1099
1111
 
1100
- alias rectangular rect
1101
-
1102
1112
  # <!--
1103
1113
  # rdoc-file=numeric.c
1104
1114
  # - remainder(other) -> real_number
@@ -1132,8 +1142,8 @@ class Integer < Numeric
1132
1142
  # Returns `self` rounded to the nearest value with a precision of `ndigits`
1133
1143
  # decimal digits.
1134
1144
  #
1135
- # When `ndigits` is negative, the returned value has at least `ndigits.abs`
1136
- # trailing zeros:
1145
+ # When `ndigits` is negative, the returned value has at least
1146
+ # <code>ndigits.abs</code> trailing zeros:
1137
1147
  #
1138
1148
  # 555.round(-1) # => 560
1139
1149
  # 555.round(-2) # => 600
@@ -1150,17 +1160,18 @@ class Integer < Numeric
1150
1160
  # If keyword argument `half` is given, and `self` is equidistant from the two
1151
1161
  # candidate values, the rounding is according to the given `half` value:
1152
1162
  #
1153
- # * `:up` or `nil`: round away from zero:
1163
+ # * <code>:up</code> or `nil`: round away from zero:
1154
1164
  #
1155
1165
  # 25.round(-1, half: :up) # => 30
1156
1166
  # (-25).round(-1, half: :up) # => -30
1157
1167
  #
1158
- # * `:down`: round toward zero:
1168
+ # * <code>:down</code>: round toward zero:
1159
1169
  #
1160
1170
  # 25.round(-1, half: :down) # => 20
1161
1171
  # (-25).round(-1, half: :down) # => -20
1162
1172
  #
1163
- # * `:even`: round toward the candidate whose last nonzero digit is even:
1173
+ # * <code>:even</code>: round toward the candidate whose last nonzero digit is
1174
+ # even:
1164
1175
  #
1165
1176
  # 25.round(-1, half: :even) # => 20
1166
1177
  # 15.round(-1, half: :even) # => 20
@@ -1170,8 +1181,7 @@ class Integer < Numeric
1170
1181
  #
1171
1182
  # Related: Integer#truncate.
1172
1183
  #
1173
- def round: (?half: :up | :down | :even) -> Integer
1174
- | (int digits, ?half: :up | :down | :even) -> (Integer | Float)
1184
+ def round: (?int digits, ?half: Numeric::round_mode) -> Integer
1175
1185
 
1176
1186
  # <!--
1177
1187
  # rdoc-file=numeric.rb
@@ -1189,22 +1199,11 @@ class Integer < Numeric
1189
1199
  #
1190
1200
  def size: () -> Integer
1191
1201
 
1192
- def step: () { (Integer) -> void } -> void
1193
- | (Numeric limit, ?Integer step) { (Integer) -> void } -> void
1194
- | (Numeric limit, ?Numeric step) { (Numeric) -> void } -> void
1195
- | (to: Numeric, ?by: Integer) { (Integer) -> void } -> void
1196
- | (by: Numeric, ?to: Numeric) { (Numeric) -> void } -> void
1197
- | () -> Enumerator[Integer, bot]
1198
- | (Numeric limit, ?Integer step) -> Enumerator[Integer]
1199
- | (Numeric limit, ?Numeric step) -> Enumerator[Numeric]
1200
- | (to: Numeric, ?by: Integer) -> Enumerator[Integer]
1201
- | (by: Numeric, ?to: Numeric) -> Enumerator[Numeric]
1202
-
1203
1202
  # <!--
1204
1203
  # rdoc-file=numeric.c
1205
1204
  # - succ -> next_integer
1206
1205
  # -->
1207
- # Returns the successor integer of `self` (equivalent to `self + 1`):
1206
+ # Returns the successor integer of `self` (equivalent to <code>self + 1</code>):
1208
1207
  #
1209
1208
  # 1.succ #=> 2
1210
1209
  # -1.succ #=> 0
@@ -1218,7 +1217,8 @@ class Integer < Numeric
1218
1217
  # - times {|i| ... } -> self
1219
1218
  # - times -> enumerator
1220
1219
  # -->
1221
- # Calls the given block `self` times with each integer in `(0..self-1)`:
1220
+ # Calls the given block `self` times with each integer in
1221
+ # <code>(0..self-1)</code>:
1222
1222
  #
1223
1223
  # a = []
1224
1224
  # 5.times {|i| a.push(i) } # => 5
@@ -1226,10 +1226,8 @@ class Integer < Numeric
1226
1226
  #
1227
1227
  # With no block given, returns an Enumerator.
1228
1228
  #
1229
- def times: () { (Integer) -> void } -> self
1230
- | () -> ::Enumerator[Integer, self]
1231
-
1232
- def to_c: () -> Complex
1229
+ def times: () { (Integer i) -> void } -> self
1230
+ | () -> Enumerator[Integer, self]
1233
1231
 
1234
1232
  # <!--
1235
1233
  # rdoc-file=numeric.c
@@ -1253,7 +1251,7 @@ class Integer < Numeric
1253
1251
  # -->
1254
1252
  # Returns `self` (which is already an Integer).
1255
1253
  #
1256
- def to_i: () -> Integer
1254
+ def to_i: () -> self
1257
1255
 
1258
1256
  # <!--
1259
1257
  # rdoc-file=numeric.rb
@@ -1291,43 +1289,7 @@ class Integer < Numeric
1291
1289
  #
1292
1290
  # Raises an exception if `base` is out of range.
1293
1291
  #
1294
- def to_s: () -> String
1295
- | (2) -> String
1296
- | (3) -> String
1297
- | (4) -> String
1298
- | (5) -> String
1299
- | (6) -> String
1300
- | (7) -> String
1301
- | (8) -> String
1302
- | (9) -> String
1303
- | (10) -> String
1304
- | (11) -> String
1305
- | (12) -> String
1306
- | (13) -> String
1307
- | (14) -> String
1308
- | (15) -> String
1309
- | (16) -> String
1310
- | (17) -> String
1311
- | (18) -> String
1312
- | (19) -> String
1313
- | (20) -> String
1314
- | (21) -> String
1315
- | (22) -> String
1316
- | (23) -> String
1317
- | (24) -> String
1318
- | (25) -> String
1319
- | (26) -> String
1320
- | (27) -> String
1321
- | (28) -> String
1322
- | (29) -> String
1323
- | (30) -> String
1324
- | (31) -> String
1325
- | (32) -> String
1326
- | (33) -> String
1327
- | (34) -> String
1328
- | (35) -> String
1329
- | (36) -> String
1330
- | (int base) -> String
1292
+ def to_s: (?int base) -> String
1331
1293
 
1332
1294
  # <!--
1333
1295
  # rdoc-file=numeric.c
@@ -1336,8 +1298,8 @@ class Integer < Numeric
1336
1298
  # Returns `self` truncated (toward zero) to a precision of `ndigits` decimal
1337
1299
  # digits.
1338
1300
  #
1339
- # When `ndigits` is negative, the returned value has at least `ndigits.abs`
1340
- # trailing zeros:
1301
+ # When `ndigits` is negative, the returned value has at least
1302
+ # <code>ndigits.abs</code> trailing zeros:
1341
1303
  #
1342
1304
  # 555.truncate(-1) # => 550
1343
1305
  # 555.truncate(-2) # => 500
@@ -1350,8 +1312,7 @@ class Integer < Numeric
1350
1312
  #
1351
1313
  # Related: Integer#round.
1352
1314
  #
1353
- def truncate: () -> Integer
1354
- | (int ndigits) -> Integer
1315
+ def truncate: (?int ndigits) -> Integer
1355
1316
 
1356
1317
  # <!--
1357
1318
  # rdoc-file=numeric.c