rbs 4.0.0.dev.4 → 4.0.0.dev.5
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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +14 -14
- data/.github/workflows/bundle-update.yml +60 -0
- data/.github/workflows/c-check.yml +11 -8
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +17 -34
- data/.github/workflows/typecheck.yml +2 -2
- data/.github/workflows/valgrind.yml +42 -0
- data/.github/workflows/windows.yml +2 -2
- data/.rubocop.yml +1 -1
- data/README.md +1 -1
- data/Rakefile +32 -5
- data/config.yml +46 -0
- data/core/array.rbs +96 -46
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +2 -2
- data/core/comparable.rbs +13 -6
- data/core/complex.rbs +55 -41
- data/core/dir.rbs +4 -4
- data/core/encoding.rbs +7 -10
- data/core/enumerable.rbs +90 -3
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator.rbs +63 -1
- data/core/errno.rbs +8 -0
- data/core/errors.rbs +28 -1
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +40 -20
- data/core/file.rbs +108 -78
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +225 -69
- data/core/gc.rbs +417 -281
- data/core/hash.rbs +1023 -727
- data/core/integer.rbs +104 -110
- data/core/io/buffer.rbs +21 -10
- data/core/io/wait.rbs +11 -33
- data/core/io.rbs +82 -19
- data/core/kernel.rbs +70 -59
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +42 -3
- data/core/method.rbs +63 -27
- data/core/module.rbs +103 -26
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +43 -35
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +21 -15
- data/core/pathname.rbs +1272 -0
- data/core/proc.rbs +30 -25
- data/core/process.rbs +4 -2
- data/core/ractor.rbs +361 -509
- data/core/random.rbs +17 -0
- data/core/range.rbs +113 -16
- data/core/rational.rbs +56 -85
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +4 -113
- data/core/regexp.rbs +25 -20
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +6 -4
- data/core/rubygems/errors.rbs +3 -70
- data/core/rubygems/rubygems.rbs +11 -79
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +488 -359
- data/core/signal.rbs +24 -14
- data/core/string.rbs +3171 -1241
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +17 -11
- data/core/thread.rbs +95 -33
- data/core/time.rbs +35 -9
- data/core/trace_point.rbs +7 -4
- data/core/unbound_method.rbs +14 -6
- data/docs/aliases.md +79 -0
- data/docs/collection.md +2 -2
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/inline.md +470 -0
- data/docs/sigs.md +3 -3
- data/docs/syntax.md +33 -4
- data/docs/type_fingerprint.md +21 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +77 -3
- data/ext/rbs_extension/ast_translation.h +3 -0
- data/ext/rbs_extension/class_constants.c +8 -2
- data/ext/rbs_extension/class_constants.h +4 -0
- data/ext/rbs_extension/extconf.rb +5 -1
- data/ext/rbs_extension/legacy_location.c +5 -5
- data/ext/rbs_extension/main.c +37 -20
- data/include/rbs/ast.h +85 -38
- data/include/rbs/defines.h +27 -0
- data/include/rbs/lexer.h +30 -11
- data/include/rbs/parser.h +6 -6
- data/include/rbs/string.h +0 -2
- data/include/rbs/util/rbs_allocator.h +34 -13
- data/include/rbs/util/rbs_assert.h +12 -1
- data/include/rbs/util/rbs_encoding.h +2 -0
- data/include/rbs/util/rbs_unescape.h +2 -1
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +10 -10
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +137 -0
- data/lib/rbs/ast/ruby/comment_block.rb +24 -0
- data/lib/rbs/ast/ruby/declarations.rb +198 -3
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
- data/lib/rbs/ast/ruby/members.rb +159 -1
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +20 -15
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +38 -51
- data/lib/rbs/cli.rb +52 -19
- data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
- data/lib/rbs/collection/sources/git.rb +1 -0
- data/lib/rbs/definition.rb +1 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
- data/lib/rbs/definition_builder/method_builder.rb +20 -0
- data/lib/rbs/definition_builder.rb +91 -2
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment.rb +227 -74
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/errors.rb +27 -7
- data/lib/rbs/inline_parser.rb +341 -5
- data/lib/rbs/location_aux.rb +1 -1
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/parser_aux.rb +2 -2
- data/lib/rbs/prototype/rb.rb +2 -2
- data/lib/rbs/prototype/rbi.rb +2 -0
- data/lib/rbs/prototype/runtime.rb +8 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +116 -38
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +16 -2
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +27 -27
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +3 -2
- data/schema/typeParam.json +17 -1
- data/sig/ast/ruby/annotations.rbs +124 -0
- data/sig/ast/ruby/comment_block.rbs +8 -0
- data/sig/ast/ruby/declarations.rbs +102 -4
- data/sig/ast/ruby/members.rbs +87 -1
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +13 -4
- data/sig/cli.rbs +18 -18
- data/sig/definition.rbs +6 -1
- data/sig/environment.rbs +70 -12
- data/sig/errors.rbs +13 -6
- data/sig/inline_parser.rbs +39 -2
- data/sig/locator.rbs +0 -2
- data/sig/manifest.yaml +0 -1
- data/sig/method_builder.rbs +3 -1
- data/sig/method_types.rbs +1 -1
- data/sig/parser.rbs +16 -2
- data/sig/resolver/type_name_resolver.rbs +35 -7
- data/sig/source.rbs +3 -3
- data/sig/type_param.rbs +13 -8
- data/sig/types.rbs +4 -4
- data/src/ast.c +80 -1
- data/src/lexer.c +1392 -1313
- data/src/lexer.re +3 -0
- data/src/lexstate.c +58 -37
- data/src/location.c +4 -4
- data/src/parser.c +412 -145
- data/src/string.c +0 -48
- data/src/util/rbs_allocator.c +89 -71
- data/src/util/rbs_assert.c +1 -1
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +10 -10
- data/src/util/rbs_encoding.c +4 -8
- data/src/util/rbs_unescape.c +56 -20
- data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +9 -393
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +171 -0
- data/stdlib/coverage/0/coverage.rbs +3 -1
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/digest/0/digest.rbs +110 -0
- data/stdlib/erb/0/erb.rbs +737 -347
- data/stdlib/fileutils/0/fileutils.rbs +20 -14
- data/stdlib/forwardable/0/forwardable.rbs +3 -0
- data/stdlib/json/0/json.rbs +82 -28
- data/stdlib/net-http/0/net-http.rbs +3 -0
- data/stdlib/objspace/0/objspace.rbs +9 -27
- data/stdlib/open-uri/0/open-uri.rbs +40 -0
- data/stdlib/open3/0/open3.rbs +459 -1
- data/stdlib/openssl/0/openssl.rbs +331 -228
- data/stdlib/optparse/0/optparse.rbs +8 -3
- data/stdlib/pathname/0/pathname.rbs +9 -1379
- data/stdlib/psych/0/psych.rbs +4 -4
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +2 -1
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/rdoc.rbs +1 -1
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +2 -2
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +6 -19
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/socket.rbs +13 -1
- data/stdlib/socket/0/tcp_socket.rbs +10 -2
- data/stdlib/stringio/0/stringio.rbs +1176 -85
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +3 -3
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/uri/0/common.rbs +16 -2
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +24 -16
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
- data/stdlib/zlib/0/gzip_reader.rbs +2 -2
- data/stdlib/zlib/0/gzip_writer.rbs +1 -1
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +30 -4
data/core/integer.rbs
CHANGED
|
@@ -146,9 +146,9 @@ class Integer < Numeric
|
|
|
146
146
|
|
|
147
147
|
# <!--
|
|
148
148
|
# rdoc-file=numeric.c
|
|
149
|
-
# - self % other ->
|
|
149
|
+
# - self % other -> real_numeric
|
|
150
150
|
# -->
|
|
151
|
-
# Returns `self` modulo `other` as a real
|
|
151
|
+
# Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
|
|
152
152
|
#
|
|
153
153
|
# For integer `n` and real number `r`, these expressions are equivalent:
|
|
154
154
|
#
|
|
@@ -193,13 +193,13 @@ class Integer < Numeric
|
|
|
193
193
|
|
|
194
194
|
# <!--
|
|
195
195
|
# rdoc-file=numeric.c
|
|
196
|
-
# - self *
|
|
196
|
+
# - self * other -> numeric
|
|
197
197
|
# -->
|
|
198
|
-
#
|
|
198
|
+
# Returns the numeric product of `self` and `other`:
|
|
199
199
|
#
|
|
200
200
|
# 4 * 2 # => 8
|
|
201
|
-
# 4 * -2 # => -8
|
|
202
201
|
# -4 * 2 # => -8
|
|
202
|
+
# 4 * -2 # => -8
|
|
203
203
|
# 4 * 2.0 # => 8.0
|
|
204
204
|
# 4 * Rational(1, 3) # => (4/3)
|
|
205
205
|
# 4 * Complex(2, 0) # => (8+0i)
|
|
@@ -211,17 +211,47 @@ class Integer < Numeric
|
|
|
211
211
|
|
|
212
212
|
# <!--
|
|
213
213
|
# rdoc-file=numeric.c
|
|
214
|
-
# - self **
|
|
214
|
+
# - self ** exponent -> numeric
|
|
215
215
|
# -->
|
|
216
|
-
#
|
|
217
|
-
#
|
|
218
|
-
#
|
|
219
|
-
# 2 **
|
|
220
|
-
#
|
|
221
|
-
#
|
|
222
|
-
# 2 ** 3
|
|
223
|
-
# 2 **
|
|
224
|
-
#
|
|
216
|
+
# Returns `self` raised to the power `exponent`:
|
|
217
|
+
#
|
|
218
|
+
# # Result for non-negative Integer exponent is Integer.
|
|
219
|
+
# 2 ** 0 # => 1
|
|
220
|
+
# 2 ** 1 # => 2
|
|
221
|
+
# 2 ** 2 # => 4
|
|
222
|
+
# 2 ** 3 # => 8
|
|
223
|
+
# -2 ** 3 # => -8
|
|
224
|
+
# # Result for negative Integer exponent is Rational, not Float.
|
|
225
|
+
# 2 ** -3 # => (1/8)
|
|
226
|
+
# -2 ** -3 # => (-1/8)
|
|
227
|
+
#
|
|
228
|
+
# # Result for Float exponent is Float.
|
|
229
|
+
# 2 ** 0.0 # => 1.0
|
|
230
|
+
# 2 ** 1.0 # => 2.0
|
|
231
|
+
# 2 ** 2.0 # => 4.0
|
|
232
|
+
# 2 ** 3.0 # => 8.0
|
|
233
|
+
# -2 ** 3.0 # => -8.0
|
|
234
|
+
# 2 ** -3.0 # => 0.125
|
|
235
|
+
# -2 ** -3.0 # => -0.125
|
|
236
|
+
#
|
|
237
|
+
# # Result for non-negative Complex exponent is Complex with Integer parts.
|
|
238
|
+
# 2 ** Complex(0, 0) # => (1+0i)
|
|
239
|
+
# 2 ** Complex(1, 0) # => (2+0i)
|
|
240
|
+
# 2 ** Complex(2, 0) # => (4+0i)
|
|
241
|
+
# 2 ** Complex(3, 0) # => (8+0i)
|
|
242
|
+
# -2 ** Complex(3, 0) # => (-8+0i)
|
|
243
|
+
# # Result for negative Complex exponent is Complex with Rational parts.
|
|
244
|
+
# 2 ** Complex(-3, 0) # => ((1/8)+(0/1)*i)
|
|
245
|
+
# -2 ** Complex(-3, 0) # => ((-1/8)+(0/1)*i)
|
|
246
|
+
#
|
|
247
|
+
# # Result for Rational exponent is Rational.
|
|
248
|
+
# 2 ** Rational(0, 1) # => (1/1)
|
|
249
|
+
# 2 ** Rational(1, 1) # => (2/1)
|
|
250
|
+
# 2 ** Rational(2, 1) # => (4/1)
|
|
251
|
+
# 2 ** Rational(3, 1) # => (8/1)
|
|
252
|
+
# -2 ** Rational(3, 1) # => (-8/1)
|
|
253
|
+
# 2 ** Rational(-3, 1) # => (1/8)
|
|
254
|
+
# -2 ** Rational(-3, 1) # => (-1/8)
|
|
225
255
|
#
|
|
226
256
|
def **: (Integer) -> Numeric
|
|
227
257
|
| (Float) -> Numeric
|
|
@@ -230,29 +260,31 @@ class Integer < Numeric
|
|
|
230
260
|
|
|
231
261
|
# <!--
|
|
232
262
|
# rdoc-file=numeric.c
|
|
233
|
-
# - self +
|
|
263
|
+
# - self + other -> numeric
|
|
234
264
|
# -->
|
|
235
|
-
#
|
|
265
|
+
# Returns the sum of `self` and `other`:
|
|
266
|
+
#
|
|
267
|
+
# 1 + 1 # => 2
|
|
268
|
+
# 1 + -1 # => 0
|
|
269
|
+
# 1 + 0 # => 1
|
|
270
|
+
# 1 + -2 # => -1
|
|
271
|
+
# 1 + Complex(1, 0) # => (2+0i)
|
|
272
|
+
# 1 + Rational(1, 1) # => (2/1)
|
|
273
|
+
#
|
|
274
|
+
# For a computation involving Floats, the result may be inexact (see Float#+):
|
|
236
275
|
#
|
|
237
|
-
#
|
|
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)
|
|
276
|
+
# 1 + 3.14 # => 4.140000000000001
|
|
243
277
|
#
|
|
244
278
|
def +: (Integer) -> Integer
|
|
245
279
|
| (Float) -> Float
|
|
246
280
|
| (Rational) -> Rational
|
|
247
281
|
| (Complex) -> Complex
|
|
248
282
|
|
|
249
|
-
def +@: () -> Integer
|
|
250
|
-
|
|
251
283
|
# <!--
|
|
252
284
|
# rdoc-file=numeric.c
|
|
253
|
-
# - self -
|
|
285
|
+
# - self - other -> numeric
|
|
254
286
|
# -->
|
|
255
|
-
#
|
|
287
|
+
# Returns the difference of `self` and `other`:
|
|
256
288
|
#
|
|
257
289
|
# 4 - 2 # => 2
|
|
258
290
|
# -4 - 2 # => -6
|
|
@@ -268,28 +300,34 @@ class Integer < Numeric
|
|
|
268
300
|
|
|
269
301
|
# <!--
|
|
270
302
|
# rdoc-file=numeric.rb
|
|
271
|
-
# - -
|
|
303
|
+
# - -self -> integer
|
|
272
304
|
# -->
|
|
273
|
-
# Returns `self`, negated
|
|
305
|
+
# Returns `self`, negated:
|
|
306
|
+
#
|
|
307
|
+
# -1 # => -1
|
|
308
|
+
# -(-1) # => 1
|
|
309
|
+
# -0 # => 0
|
|
274
310
|
#
|
|
275
311
|
def -@: () -> Integer
|
|
276
312
|
|
|
277
313
|
# <!--
|
|
278
314
|
# rdoc-file=numeric.c
|
|
279
|
-
# - self /
|
|
315
|
+
# - self / other -> numeric
|
|
280
316
|
# -->
|
|
281
|
-
#
|
|
317
|
+
# Returns the quotient of `self` and `other`.
|
|
318
|
+
#
|
|
319
|
+
# For integer `other`, truncates the result to an integer:
|
|
282
320
|
#
|
|
283
|
-
#
|
|
284
|
-
#
|
|
285
|
-
#
|
|
286
|
-
#
|
|
321
|
+
# 4 / 3 # => 1
|
|
322
|
+
# 4 / -3 # => -2
|
|
323
|
+
# -4 / 3 # => -2
|
|
324
|
+
# -4 / -3 # => 1
|
|
287
325
|
#
|
|
288
|
-
#
|
|
326
|
+
# For non-integer `other`, returns a non-integer result:
|
|
289
327
|
#
|
|
290
|
-
#
|
|
291
|
-
#
|
|
292
|
-
#
|
|
328
|
+
# 4 / 3.0 # => 1.3333333333333333
|
|
329
|
+
# 4 / Rational(3, 1) # => (4/3)
|
|
330
|
+
# 4 / Complex(3, 0) # => ((4/3)+0i)
|
|
293
331
|
#
|
|
294
332
|
def /: (Integer) -> Integer
|
|
295
333
|
| (Float) -> Float
|
|
@@ -300,15 +338,14 @@ class Integer < Numeric
|
|
|
300
338
|
# rdoc-file=numeric.c
|
|
301
339
|
# - self < other -> true or false
|
|
302
340
|
# -->
|
|
303
|
-
# Returns
|
|
341
|
+
# Returns whether the value of `self` is less than the value of `other`; `other`
|
|
342
|
+
# must be numeric, but may not be Complex:
|
|
304
343
|
#
|
|
305
|
-
#
|
|
306
|
-
#
|
|
307
|
-
#
|
|
308
|
-
#
|
|
309
|
-
#
|
|
310
|
-
#
|
|
311
|
-
# Raises an exception if the comparison cannot be made.
|
|
344
|
+
# 1 < 0 # => false
|
|
345
|
+
# 1 < 1 # => false
|
|
346
|
+
# 1 < 2 # => true
|
|
347
|
+
# 1 < 0.5 # => false
|
|
348
|
+
# 1 < Rational(1, 2) # => false
|
|
312
349
|
#
|
|
313
350
|
def <: (Numeric) -> bool
|
|
314
351
|
|
|
@@ -331,44 +368,46 @@ class Integer < Numeric
|
|
|
331
368
|
|
|
332
369
|
# <!--
|
|
333
370
|
# rdoc-file=numeric.c
|
|
334
|
-
# - self <=
|
|
371
|
+
# - self <= other -> true or false
|
|
335
372
|
# -->
|
|
336
|
-
# Returns
|
|
337
|
-
# `other
|
|
373
|
+
# Returns whether the value of `self` is less than or equal to the value of
|
|
374
|
+
# `other`; `other` must be numeric, but may not be Complex:
|
|
338
375
|
#
|
|
339
|
-
#
|
|
340
|
-
#
|
|
341
|
-
#
|
|
342
|
-
#
|
|
343
|
-
#
|
|
376
|
+
# 1 <= 0 # => false
|
|
377
|
+
# 1 <= 1 # => true
|
|
378
|
+
# 1 <= 2 # => true
|
|
379
|
+
# 1 <= 0.5 # => false
|
|
380
|
+
# 1 <= Rational(1, 2) # => false
|
|
344
381
|
#
|
|
345
|
-
#
|
|
382
|
+
# Raises an exception if the comparison cannot be made.
|
|
346
383
|
#
|
|
347
384
|
def <=: (Numeric) -> bool
|
|
348
385
|
|
|
349
386
|
# <!--
|
|
350
387
|
# rdoc-file=numeric.c
|
|
351
|
-
# - self <=> other
|
|
388
|
+
# - self <=> other -> -1, 0, 1, or nil
|
|
352
389
|
# -->
|
|
390
|
+
# Compares `self` and `other`.
|
|
391
|
+
#
|
|
353
392
|
# Returns:
|
|
354
393
|
#
|
|
355
|
-
# *
|
|
356
|
-
# * 0
|
|
357
|
-
# * 1
|
|
394
|
+
# * `-1`, if `self` is less than `other`.
|
|
395
|
+
# * `0`, if `self` is equal to `other`.
|
|
396
|
+
# * `1`, if `self` is greater then `other`.
|
|
358
397
|
# * `nil`, if `self` and `other` are incomparable.
|
|
359
398
|
#
|
|
360
399
|
# Examples:
|
|
361
400
|
#
|
|
362
401
|
# 1 <=> 2 # => -1
|
|
363
402
|
# 1 <=> 1 # => 0
|
|
364
|
-
# 1 <=> 0 # => 1
|
|
365
|
-
# 1 <=> 'foo' # => nil
|
|
366
|
-
#
|
|
367
403
|
# 1 <=> 1.0 # => 0
|
|
368
404
|
# 1 <=> Rational(1, 1) # => 0
|
|
369
405
|
# 1 <=> Complex(1, 0) # => 0
|
|
406
|
+
# 1 <=> 0 # => 1
|
|
407
|
+
# 1 <=> 'foo' # => nil
|
|
370
408
|
#
|
|
371
|
-
#
|
|
409
|
+
# Class Integer includes module Comparable, each of whose methods uses
|
|
410
|
+
# Integer#<=> for comparison.
|
|
372
411
|
#
|
|
373
412
|
def <=>: (Integer | Rational) -> Integer
|
|
374
413
|
| (untyped) -> Integer?
|
|
@@ -515,8 +554,6 @@ class Integer < Numeric
|
|
|
515
554
|
#
|
|
516
555
|
def abs: () -> Integer
|
|
517
556
|
|
|
518
|
-
def abs2: () -> Integer
|
|
519
|
-
|
|
520
557
|
# <!--
|
|
521
558
|
# rdoc-file=numeric.c
|
|
522
559
|
# - allbits?(mask) -> true or false
|
|
@@ -540,8 +577,6 @@ class Integer < Numeric
|
|
|
540
577
|
#
|
|
541
578
|
def allbits?: (int mask) -> bool
|
|
542
579
|
|
|
543
|
-
def angle: () -> (Integer | Float)
|
|
544
|
-
|
|
545
580
|
# <!--
|
|
546
581
|
# rdoc-file=numeric.c
|
|
547
582
|
# - anybits?(mask) -> true or false
|
|
@@ -706,10 +741,6 @@ class Integer < Numeric
|
|
|
706
741
|
#
|
|
707
742
|
def coerce: (Numeric) -> [ Numeric, Numeric ]
|
|
708
743
|
|
|
709
|
-
def conj: () -> Integer
|
|
710
|
-
|
|
711
|
-
def conjugate: () -> Integer
|
|
712
|
-
|
|
713
744
|
# <!--
|
|
714
745
|
# rdoc-file=numeric.rb
|
|
715
746
|
# - denominator -> 1
|
|
@@ -801,10 +832,6 @@ class Integer < Numeric
|
|
|
801
832
|
def downto: (Numeric limit) { (Integer) -> void } -> Integer
|
|
802
833
|
| (Numeric limit) -> ::Enumerator[Integer, self]
|
|
803
834
|
|
|
804
|
-
def dup: () -> self
|
|
805
|
-
|
|
806
|
-
def eql?: (untyped) -> bool
|
|
807
|
-
|
|
808
835
|
# <!--
|
|
809
836
|
# rdoc-file=numeric.rb
|
|
810
837
|
# - even? -> true or false
|
|
@@ -829,8 +856,6 @@ class Integer < Numeric
|
|
|
829
856
|
#
|
|
830
857
|
def fdiv: (Numeric) -> Float
|
|
831
858
|
|
|
832
|
-
def finite?: () -> bool
|
|
833
|
-
|
|
834
859
|
# <!--
|
|
835
860
|
# rdoc-file=numeric.c
|
|
836
861
|
# - floor(ndigits = 0) -> integer
|
|
@@ -901,14 +926,6 @@ class Integer < Numeric
|
|
|
901
926
|
#
|
|
902
927
|
def gcdlcm: (Integer) -> [ Integer, Integer ]
|
|
903
928
|
|
|
904
|
-
def i: () -> Complex
|
|
905
|
-
|
|
906
|
-
def imag: () -> Integer
|
|
907
|
-
|
|
908
|
-
def imaginary: () -> Integer
|
|
909
|
-
|
|
910
|
-
def infinite?: () -> Integer?
|
|
911
|
-
|
|
912
929
|
# <!-- rdoc-file=numeric.c -->
|
|
913
930
|
# Returns a string containing the place-value representation of `self` in radix
|
|
914
931
|
# `base` (in 2..36).
|
|
@@ -955,7 +972,7 @@ class Integer < Numeric
|
|
|
955
972
|
def magnitude: () -> Integer
|
|
956
973
|
|
|
957
974
|
# <!-- rdoc-file=numeric.c -->
|
|
958
|
-
# Returns `self` modulo `other` as a real
|
|
975
|
+
# Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
|
|
959
976
|
#
|
|
960
977
|
# For integer `n` and real number `r`, these expressions are equivalent:
|
|
961
978
|
#
|
|
@@ -1015,8 +1032,6 @@ class Integer < Numeric
|
|
|
1015
1032
|
#
|
|
1016
1033
|
def nobits?: (int mask) -> bool
|
|
1017
1034
|
|
|
1018
|
-
def nonzero?: () -> self?
|
|
1019
|
-
|
|
1020
1035
|
# <!--
|
|
1021
1036
|
# rdoc-file=numeric.rb
|
|
1022
1037
|
# - numerator -> self
|
|
@@ -1041,8 +1056,6 @@ class Integer < Numeric
|
|
|
1041
1056
|
#
|
|
1042
1057
|
def ord: () -> Integer
|
|
1043
1058
|
|
|
1044
|
-
alias phase angle
|
|
1045
|
-
|
|
1046
1059
|
def polar: () -> [ Integer, Integer | Float ]
|
|
1047
1060
|
|
|
1048
1061
|
def positive?: () -> bool
|
|
@@ -1091,14 +1104,8 @@ class Integer < Numeric
|
|
|
1091
1104
|
#
|
|
1092
1105
|
def rationalize: (?Numeric eps) -> Rational
|
|
1093
1106
|
|
|
1094
|
-
def real: () -> self
|
|
1095
|
-
|
|
1096
|
-
def real?: () -> true
|
|
1097
|
-
|
|
1098
1107
|
def rect: () -> [ Integer, Numeric ]
|
|
1099
1108
|
|
|
1100
|
-
alias rectangular rect
|
|
1101
|
-
|
|
1102
1109
|
# <!--
|
|
1103
1110
|
# rdoc-file=numeric.c
|
|
1104
1111
|
# - remainder(other) -> real_number
|
|
@@ -1189,17 +1196,6 @@ class Integer < Numeric
|
|
|
1189
1196
|
#
|
|
1190
1197
|
def size: () -> Integer
|
|
1191
1198
|
|
|
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
1199
|
# <!--
|
|
1204
1200
|
# rdoc-file=numeric.c
|
|
1205
1201
|
# - succ -> next_integer
|
|
@@ -1229,8 +1225,6 @@ class Integer < Numeric
|
|
|
1229
1225
|
def times: () { (Integer) -> void } -> self
|
|
1230
1226
|
| () -> ::Enumerator[Integer, self]
|
|
1231
1227
|
|
|
1232
|
-
def to_c: () -> Complex
|
|
1233
|
-
|
|
1234
1228
|
# <!--
|
|
1235
1229
|
# rdoc-file=numeric.c
|
|
1236
1230
|
# - to_f -> float
|
data/core/io/buffer.rbs
CHANGED
|
@@ -64,9 +64,9 @@ class IO
|
|
|
64
64
|
#
|
|
65
65
|
# File.write('test.txt', 'test data')
|
|
66
66
|
# # => 9
|
|
67
|
-
# buffer = IO::Buffer.map(File.open('test.txt'))
|
|
67
|
+
# buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
|
|
68
68
|
# # =>
|
|
69
|
-
# # #<IO::Buffer 0x00007f3f0768c000+9 MAPPED
|
|
69
|
+
# # #<IO::Buffer 0x00007f3f0768c000+9 EXTERNAL MAPPED FILE SHARED READONLY>
|
|
70
70
|
# # ...
|
|
71
71
|
# buffer.get_string(5, 2) # read 2 bytes, starting from offset 5
|
|
72
72
|
# # => "da"
|
|
@@ -113,7 +113,7 @@ class IO
|
|
|
113
113
|
# buffer.get_string(0, 1)
|
|
114
114
|
# # => "t"
|
|
115
115
|
# string
|
|
116
|
-
# # => "
|
|
116
|
+
# # => "test"
|
|
117
117
|
#
|
|
118
118
|
# buffer.resize(100)
|
|
119
119
|
# # in `resize': Cannot resize external buffer! (IO::Buffer::AccessError)
|
|
@@ -131,18 +131,25 @@ class IO
|
|
|
131
131
|
# - IO::Buffer.map(file, [size, [offset, [flags]]]) -> io_buffer
|
|
132
132
|
# -->
|
|
133
133
|
# Create an IO::Buffer for reading from `file` by memory-mapping the file.
|
|
134
|
-
# `
|
|
134
|
+
# `file` should be a `File` instance, opened for reading or reading and writing.
|
|
135
|
+
#
|
|
136
|
+
# Optional `size` and `offset` of mapping can be specified. Trying to map an
|
|
137
|
+
# empty file or specify `size` of 0 will raise an error. Valid values for
|
|
138
|
+
# `offset` are system-dependent.
|
|
135
139
|
#
|
|
136
|
-
#
|
|
140
|
+
# By default, the buffer is writable and expects the file to be writable. It is
|
|
141
|
+
# also shared, so several processes can use the same mapping.
|
|
137
142
|
#
|
|
138
|
-
#
|
|
139
|
-
#
|
|
140
|
-
# `flags`
|
|
143
|
+
# You can pass IO::Buffer::READONLY in `flags` argument to make a read-only
|
|
144
|
+
# buffer; this allows to work with files opened only for reading. Specifying
|
|
145
|
+
# IO::Buffer::PRIVATE in `flags` creates a private mapping, which will not
|
|
146
|
+
# impact other processes or the underlying file. It also allows updating a
|
|
147
|
+
# buffer created from a read-only file.
|
|
141
148
|
#
|
|
142
149
|
# File.write('test.txt', 'test')
|
|
143
150
|
#
|
|
144
151
|
# buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
|
|
145
|
-
# # => #<IO::Buffer 0x00000001014a0000+4 MAPPED READONLY>
|
|
152
|
+
# # => #<IO::Buffer 0x00000001014a0000+4 EXTERNAL MAPPED FILE SHARED READONLY>
|
|
146
153
|
#
|
|
147
154
|
# buffer.readonly? # => true
|
|
148
155
|
#
|
|
@@ -150,7 +157,7 @@ class IO
|
|
|
150
157
|
# # => "test"
|
|
151
158
|
#
|
|
152
159
|
# buffer.set_string('b', 0)
|
|
153
|
-
# #
|
|
160
|
+
# # 'IO::Buffer#set_string': Buffer is not writable! (IO::Buffer::AccessError)
|
|
154
161
|
#
|
|
155
162
|
# # create read/write mapping: length 4 bytes, offset 0, flags 0
|
|
156
163
|
# buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0)
|
|
@@ -382,6 +389,10 @@ class IO
|
|
|
382
389
|
# * `:U64`: unsigned integer, 8 bytes, big-endian
|
|
383
390
|
# * `:s64`: signed integer, 8 bytes, little-endian
|
|
384
391
|
# * `:S64`: signed integer, 8 bytes, big-endian
|
|
392
|
+
# * `:u128`: unsigned integer, 16 bytes, little-endian
|
|
393
|
+
# * `:U128`: unsigned integer, 16 bytes, big-endian
|
|
394
|
+
# * `:s128`: signed integer, 16 bytes, little-endian
|
|
395
|
+
# * `:S128`: signed integer, 16 bytes, big-endian
|
|
385
396
|
# * `:f32`: float, 4 bytes, little-endian
|
|
386
397
|
# * `:F32`: float, 4 bytes, big-endian
|
|
387
398
|
# * `:f64`: double, 8 bytes, little-endian
|
data/core/io/wait.rbs
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
%a{annotate:rdoc:skip}
|
|
2
2
|
class IO
|
|
3
3
|
# <!--
|
|
4
|
-
# rdoc-file=
|
|
5
|
-
# - io.nread -> int
|
|
6
|
-
# -->
|
|
7
|
-
# Returns number of bytes that can be read without blocking. Returns zero if no
|
|
8
|
-
# information available.
|
|
9
|
-
#
|
|
10
|
-
# You must require 'io/wait' to use this method.
|
|
11
|
-
#
|
|
12
|
-
def nread: () -> Integer
|
|
13
|
-
|
|
14
|
-
# <!--
|
|
15
|
-
# rdoc-file=ext/io/wait/wait.c
|
|
16
|
-
# - io.ready? -> truthy or falsy
|
|
17
|
-
# -->
|
|
18
|
-
# Returns a truthy value if input available without blocking, or a falsy value.
|
|
19
|
-
#
|
|
20
|
-
# You must require 'io/wait' to use this method.
|
|
21
|
-
#
|
|
22
|
-
def ready?: () -> boolish
|
|
23
|
-
|
|
24
|
-
# <!--
|
|
25
|
-
# rdoc-file=ext/io/wait/wait.c
|
|
4
|
+
# rdoc-file=io.c
|
|
26
5
|
# - io.wait(events, timeout) -> event mask, false or nil
|
|
27
|
-
# - io.wait(
|
|
6
|
+
# - io.wait(*event_symbols[, timeout]) -> self, true, or false
|
|
28
7
|
# -->
|
|
29
8
|
# Waits until the IO becomes ready for the specified events and returns the
|
|
30
9
|
# subset of events that become ready, or a falsy value when times out.
|
|
@@ -32,11 +11,14 @@ class IO
|
|
|
32
11
|
# The events can be a bit mask of `IO::READABLE`, `IO::WRITABLE` or
|
|
33
12
|
# `IO::PRIORITY`.
|
|
34
13
|
#
|
|
35
|
-
# Returns
|
|
36
|
-
#
|
|
37
|
-
# Optional parameter `mode` is one of `:read`, `:write`, or `:read_write`.
|
|
14
|
+
# Returns an event mask (truthy value) immediately when buffered data is
|
|
15
|
+
# available.
|
|
38
16
|
#
|
|
39
|
-
#
|
|
17
|
+
# The second form: if one or more event symbols (`:read`, `:write`, or
|
|
18
|
+
# `:read_write`) are passed, the event mask is the bit OR of the bitmask
|
|
19
|
+
# corresponding to those symbols. In this form, `timeout` is optional, the
|
|
20
|
+
# order of the arguments is arbitrary, and returns `io` if any of the events is
|
|
21
|
+
# ready.
|
|
40
22
|
#
|
|
41
23
|
def wait: (Integer events, ?Time::_Timeout timeout) -> (Integer | false | nil)
|
|
42
24
|
| (?Time::_Timeout? timeout, *wait_mode mode) -> (self | true | false)
|
|
@@ -44,7 +26,7 @@ class IO
|
|
|
44
26
|
type wait_mode = :read | :r | :readable | :write | :w | :writable | :read_write | :rw | :readable_writable
|
|
45
27
|
|
|
46
28
|
# <!--
|
|
47
|
-
# rdoc-file=
|
|
29
|
+
# rdoc-file=io.c
|
|
48
30
|
# - io.wait_readable -> truthy or falsy
|
|
49
31
|
# - io.wait_readable(timeout) -> truthy or falsy
|
|
50
32
|
# -->
|
|
@@ -52,19 +34,15 @@ class IO
|
|
|
52
34
|
# times out. Returns a truthy value immediately when buffered data is
|
|
53
35
|
# available.
|
|
54
36
|
#
|
|
55
|
-
# You must require 'io/wait' to use this method.
|
|
56
|
-
#
|
|
57
37
|
def wait_readable: (?Time::_Timeout? timeout) -> boolish
|
|
58
38
|
|
|
59
39
|
# <!--
|
|
60
|
-
# rdoc-file=
|
|
40
|
+
# rdoc-file=io.c
|
|
61
41
|
# - io.wait_writable -> truthy or falsy
|
|
62
42
|
# - io.wait_writable(timeout) -> truthy or falsy
|
|
63
43
|
# -->
|
|
64
44
|
# Waits until IO is writable and returns a truthy value or a falsy value when
|
|
65
45
|
# times out.
|
|
66
46
|
#
|
|
67
|
-
# You must require 'io/wait' to use this method.
|
|
68
|
-
#
|
|
69
47
|
def wait_writable: (?Time::_Timeout? timeout) -> boolish
|
|
70
48
|
end
|