rbs 3.4.0.pre.1 → 3.4.1
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/workflows/comments.yml +1 -1
- data/CHANGELOG.md +21 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/Rakefile +2 -2
- data/core/complex.rbs +290 -177
- data/core/dir.rbs +22 -9
- data/core/errors.rbs +1 -5
- data/core/file.rbs +152 -37
- data/core/float.rbs +4 -6
- data/core/gc.rbs +1 -0
- data/core/io/buffer.rbs +126 -47
- data/core/io.rbs +24 -5
- data/core/kernel.rbs +3 -3
- data/core/match_data.rbs +24 -14
- data/core/module.rbs +23 -18
- data/core/numeric.rbs +13 -16
- data/core/object_space/weak_key_map.rbs +78 -11
- data/core/object_space.rbs +2 -0
- data/core/process.rbs +4 -3
- data/core/range.rbs +10 -9
- data/core/refinement.rbs +10 -1
- data/core/string.rbs +24 -25
- data/core/thread.rbs +4 -4
- data/core/trace_point.rbs +7 -4
- data/docs/gem.md +58 -0
- data/lib/rbs/test/errors.rb +6 -1
- data/lib/rbs/version.rb +1 -1
- data/stdlib/bigdecimal/0/big_decimal.rbs +28 -29
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +6 -6
- data/stdlib/pty/0/pty.rbs +1 -7
- data/stdlib/socket/0/addrinfo.rbs +4 -0
- data/stdlib/socket/0/basic_socket.rbs +4 -2
- data/stdlib/socket/0/socket.rbs +4 -3
- data/stdlib/socket/0/udp_socket.rbs +4 -2
- metadata +4 -3
data/core/io/buffer.rbs
CHANGED
@@ -1,26 +1,29 @@
|
|
1
1
|
%a{annotate:rdoc:skip}
|
2
2
|
class IO
|
3
3
|
# <!-- rdoc-file=io_buffer.c -->
|
4
|
-
# IO::Buffer is a
|
5
|
-
#
|
4
|
+
# IO::Buffer is a efficient zero-copy buffer for input/output. There are typical
|
5
|
+
# use cases:
|
6
6
|
#
|
7
7
|
# * Create an empty buffer with ::new, fill it with buffer using #copy or
|
8
|
-
# #set_value, #set_string, get buffer with #get_string
|
8
|
+
# #set_value, #set_string, get buffer with #get_string or write it directly
|
9
|
+
# to some file with #write.
|
9
10
|
# * Create a buffer mapped to some string with ::for, then it could be used
|
10
11
|
# both for reading with #get_string or #get_value, and writing (writing will
|
11
|
-
# change the source string, too)
|
12
|
+
# change the source string, too).
|
12
13
|
# * Create a buffer mapped to some file with ::map, then it could be used for
|
13
14
|
# reading and writing the underlying file.
|
15
|
+
# * Create a string of a fixed size with ::string, then #read into it, or
|
16
|
+
# modify it using #set_value.
|
14
17
|
#
|
15
18
|
#
|
16
19
|
# Interaction with string and file memory is performed by efficient low-level C
|
17
20
|
# mechanisms like `memcpy`.
|
18
21
|
#
|
19
22
|
# The class is meant to be an utility for implementing more high-level
|
20
|
-
# mechanisms like Fiber::
|
21
|
-
#
|
23
|
+
# mechanisms like Fiber::Scheduler#io_read and Fiber::Scheduler#io_write and
|
24
|
+
# parsing binary protocols.
|
22
25
|
#
|
23
|
-
#
|
26
|
+
# ## Examples of Usage
|
24
27
|
#
|
25
28
|
# Empty buffer:
|
26
29
|
#
|
@@ -81,7 +84,9 @@ class IO
|
|
81
84
|
# File.read('test.txt')
|
82
85
|
# # => "t--- buffer"
|
83
86
|
#
|
84
|
-
# **The class is experimental and the interface is subject to change
|
87
|
+
# **The class is experimental and the interface is subject to change, this is
|
88
|
+
# especially true of file mappings which may be removed entirely in the
|
89
|
+
# future.**
|
85
90
|
#
|
86
91
|
class Buffer
|
87
92
|
include Comparable
|
@@ -91,10 +96,11 @@ class IO
|
|
91
96
|
# - IO::Buffer.for(string) -> readonly io_buffer
|
92
97
|
# - IO::Buffer.for(string) {|io_buffer| ... read/write io_buffer ...}
|
93
98
|
# -->
|
94
|
-
# Creates a IO::Buffer from the given string's memory. Without a block
|
95
|
-
# internal copy of the string is created efficiently and used as the
|
96
|
-
# source. When a block is provided, the buffer is associated directly
|
97
|
-
# string's internal buffer and updating the buffer will update the
|
99
|
+
# Creates a zero-copy IO::Buffer from the given string's memory. Without a block
|
100
|
+
# a frozen internal copy of the string is created efficiently and used as the
|
101
|
+
# buffer source. When a block is provided, the buffer is associated directly
|
102
|
+
# with the string's internal buffer and updating the buffer will update the
|
103
|
+
# string.
|
98
104
|
#
|
99
105
|
# Until #free is invoked on the buffer, either explicitly or via the garbage
|
100
106
|
# collector, the source string will be locked and cannot be modified.
|
@@ -136,8 +142,6 @@ class IO
|
|
136
142
|
# mapping, you need to open a file in read-write mode, and explicitly pass
|
137
143
|
# `flags` argument without IO::Buffer::IMMUTABLE.
|
138
144
|
#
|
139
|
-
# Example:
|
140
|
-
#
|
141
145
|
# File.write('test.txt', 'test')
|
142
146
|
#
|
143
147
|
# buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
|
@@ -169,9 +173,9 @@ class IO
|
|
169
173
|
# rdoc-file=io_buffer.c
|
170
174
|
# - IO::Buffer.string(length) {|io_buffer| ... read/write io_buffer ...} -> string
|
171
175
|
# -->
|
172
|
-
# Creates a new string of the given length and yields a IO::Buffer
|
173
|
-
# the block which uses the string as a source. The block is expected
|
174
|
-
# the buffer and the string will be returned.
|
176
|
+
# Creates a new string of the given length and yields a zero-copy IO::Buffer
|
177
|
+
# instance to the block which uses the string as a source. The block is expected
|
178
|
+
# to write to the buffer and the string will be returned.
|
175
179
|
#
|
176
180
|
# IO::Buffer.string(4) do |buffer|
|
177
181
|
# buffer.set_string("Ruby")
|
@@ -316,8 +320,6 @@ class IO
|
|
316
320
|
#
|
317
321
|
# You can resize a freed buffer to re-allocate it.
|
318
322
|
#
|
319
|
-
# Example:
|
320
|
-
#
|
321
323
|
# buffer = IO::Buffer.for('test')
|
322
324
|
# buffer.free
|
323
325
|
# # => #<IO::Buffer 0x0000000000000000+0 NULL>
|
@@ -381,8 +383,6 @@ class IO
|
|
381
383
|
# in the buffer. For example, a `:u32` buffer type is a 32-bit unsigned integer
|
382
384
|
# in little-endian format.
|
383
385
|
#
|
384
|
-
# Example:
|
385
|
-
#
|
386
386
|
# string = [1.5].pack('f')
|
387
387
|
# # => "\x00\x00\xC0?"
|
388
388
|
# IO::Buffer.for(string).get_value(:f32, 0)
|
@@ -400,15 +400,35 @@ class IO
|
|
400
400
|
|
401
401
|
# <!--
|
402
402
|
# rdoc-file=io_buffer.c
|
403
|
-
# - hexdump()
|
403
|
+
# - hexdump([offset, [length, [width]]]) -> string
|
404
404
|
# -->
|
405
|
+
# Returns a human-readable string representation of the buffer. The exact format
|
406
|
+
# is subject to change.
|
407
|
+
#
|
408
|
+
# buffer = IO::Buffer.for("Hello World")
|
409
|
+
# puts buffer.hexdump
|
410
|
+
# # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World
|
411
|
+
#
|
412
|
+
# As buffers are usually fairly big, you may want to limit the output by
|
413
|
+
# specifying the offset and length:
|
414
|
+
#
|
415
|
+
# puts buffer.hexdump(6, 5)
|
416
|
+
# # 0x00000006 57 6f 72 6c 64 World
|
405
417
|
#
|
406
418
|
def hexdump: () -> String
|
407
419
|
|
408
420
|
# <!--
|
409
421
|
# rdoc-file=io_buffer.c
|
410
|
-
# - inspect
|
422
|
+
# - inspect -> string
|
411
423
|
# -->
|
424
|
+
# Inspect the buffer and report useful information about it's internal state.
|
425
|
+
# Only a limited portion of the buffer will be displayed in a hexdump style
|
426
|
+
# format.
|
427
|
+
#
|
428
|
+
# buffer = IO::Buffer.for("Hello World")
|
429
|
+
# puts buffer.inspect
|
430
|
+
# # #<IO::Buffer 0x000000010198ccd8+11 EXTERNAL READONLY SLICE>
|
431
|
+
# # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World
|
412
432
|
#
|
413
433
|
def inspect: () -> String
|
414
434
|
|
@@ -445,8 +465,6 @@ class IO
|
|
445
465
|
# system calls. You can only share a buffer between threads with appropriate
|
446
466
|
# synchronisation techniques.
|
447
467
|
#
|
448
|
-
# Example:
|
449
|
-
#
|
450
468
|
# buffer = IO::Buffer.new(4)
|
451
469
|
# buffer.locked? #=> false
|
452
470
|
#
|
@@ -476,8 +494,6 @@ class IO
|
|
476
494
|
# Locking is not thread safe, but is a semantic used to ensure buffers don't
|
477
495
|
# move while being used by a system call.
|
478
496
|
#
|
479
|
-
# Example:
|
480
|
-
#
|
481
497
|
# buffer.locked do
|
482
498
|
# buffer.write(io) # theoretical system call interface
|
483
499
|
# end
|
@@ -503,7 +519,16 @@ class IO
|
|
503
519
|
# rdoc-file=io_buffer.c
|
504
520
|
# - null? -> true or false
|
505
521
|
# -->
|
506
|
-
# If the buffer was freed with #free or was never
|
522
|
+
# If the buffer was freed with #free, transferred with #transfer, or was never
|
523
|
+
# allocated in the first place.
|
524
|
+
#
|
525
|
+
# buffer = IO::Buffer.new(0)
|
526
|
+
# buffer.null? #=> true
|
527
|
+
#
|
528
|
+
# buffer = IO::Buffer.new(4)
|
529
|
+
# buffer.null? #=> false
|
530
|
+
# buffer.free
|
531
|
+
# buffer.null? #=> true
|
507
532
|
#
|
508
533
|
def null?: () -> bool
|
509
534
|
|
@@ -523,8 +548,6 @@ class IO
|
|
523
548
|
# If `offset` is not given, it defaults to zero, i.e. the beginning of the
|
524
549
|
# buffer.
|
525
550
|
#
|
526
|
-
# Example:
|
527
|
-
#
|
528
551
|
# IO::Buffer.for('test') do |buffer|
|
529
552
|
# p buffer
|
530
553
|
# # =>
|
@@ -561,8 +584,6 @@ class IO
|
|
561
584
|
# If the `from` position is beyond the end of the file, the gap will be filled
|
562
585
|
# with null (0 value) bytes.
|
563
586
|
#
|
564
|
-
# Example:
|
565
|
-
#
|
566
587
|
# out = File.open('output.txt', File::RDWR) # open for read/write, no truncation
|
567
588
|
# IO::Buffer.for('1234567').pwrite(out, 2, 3, 1)
|
568
589
|
#
|
@@ -586,8 +607,6 @@ class IO
|
|
586
607
|
# If `offset` is not given, it defaults to zero, i.e. the beginning of the
|
587
608
|
# buffer.
|
588
609
|
#
|
589
|
-
# Example:
|
590
|
-
#
|
591
610
|
# IO::Buffer.for('test') do |buffer|
|
592
611
|
# p buffer
|
593
612
|
# # =>
|
@@ -636,8 +655,8 @@ class IO
|
|
636
655
|
# rdoc-file=io_buffer.c
|
637
656
|
# - set_string(string, [offset, [length, [source_offset]]]) -> size
|
638
657
|
# -->
|
639
|
-
# Efficiently copy
|
640
|
-
#
|
658
|
+
# Efficiently copy from a source String into the buffer, at `offset` using
|
659
|
+
# `memcpy`.
|
641
660
|
#
|
642
661
|
# buf = IO::Buffer.new(8)
|
643
662
|
# # =>
|
@@ -721,8 +740,6 @@ class IO
|
|
721
740
|
# Raises RuntimeError if the `offset+length` is out of the current buffer's
|
722
741
|
# bounds.
|
723
742
|
#
|
724
|
-
# Example:
|
725
|
-
#
|
726
743
|
# string = 'test'
|
727
744
|
# buffer = IO::Buffer.for(string)
|
728
745
|
#
|
@@ -776,9 +793,8 @@ class IO
|
|
776
793
|
# rdoc-file=io_buffer.c
|
777
794
|
# - transfer -> new_io_buffer
|
778
795
|
# -->
|
779
|
-
# Transfers ownership to a new buffer,
|
780
|
-
#
|
781
|
-
# Example:
|
796
|
+
# Transfers ownership of the underlying memory to a new buffer, causing the
|
797
|
+
# current buffer to become uninitialized.
|
782
798
|
#
|
783
799
|
# buffer = IO::Buffer.new('test')
|
784
800
|
# other = buffer.transfer
|
@@ -800,8 +816,8 @@ class IO
|
|
800
816
|
# -->
|
801
817
|
# Returns whether the buffer buffer is accessible.
|
802
818
|
#
|
803
|
-
# A buffer becomes invalid if it is a slice of another buffer
|
804
|
-
# freed.
|
819
|
+
# A buffer becomes invalid if it is a slice of another buffer (or string) which
|
820
|
+
# has been freed or re-allocated at a different address.
|
805
821
|
#
|
806
822
|
def valid?: () -> bool
|
807
823
|
|
@@ -820,8 +836,6 @@ class IO
|
|
820
836
|
# If `offset` is not given, it defaults to zero, i.e. the beginning of the
|
821
837
|
# buffer.
|
822
838
|
#
|
823
|
-
# Example:
|
824
|
-
#
|
825
839
|
# out = File.open('output.txt', 'wb')
|
826
840
|
# IO::Buffer.for('1234567').write(out, 3)
|
827
841
|
#
|
@@ -842,8 +856,6 @@ class IO
|
|
842
856
|
# Unix, `VirtualAlloc` on Windows). The behavior can be forced by passing
|
843
857
|
# IO::Buffer::MAPPED as a second parameter.
|
844
858
|
#
|
845
|
-
# Examples
|
846
|
-
#
|
847
859
|
# buffer = IO::Buffer.new(4)
|
848
860
|
# # =>
|
849
861
|
# # #<IO::Buffer 0x000055b34497ea10+4 INTERNAL>
|
@@ -859,42 +871,109 @@ class IO
|
|
859
871
|
#
|
860
872
|
def initialize: (?Integer size, ?Integer flags) -> void
|
861
873
|
|
874
|
+
# <!-- rdoc-file=io_buffer.c -->
|
875
|
+
# Refers to big endian byte order, where the most significant byte is stored
|
876
|
+
# first. See #get_value for more details.
|
877
|
+
#
|
862
878
|
BIG_ENDIAN: Integer
|
863
879
|
|
880
|
+
# <!-- rdoc-file=io_buffer.c -->
|
881
|
+
# The default buffer size, typically a (small) multiple of the PAGE_SIZE. Can be
|
882
|
+
# explicitly specified by setting the RUBY_IO_BUFFER_DEFAULT_SIZE environment
|
883
|
+
# variable.
|
884
|
+
#
|
864
885
|
DEFAULT_SIZE: Integer
|
865
886
|
|
887
|
+
# <!-- rdoc-file=io_buffer.c -->
|
888
|
+
# Indicates that the memory in the buffer is owned by someone else. See
|
889
|
+
# #external? for more details.
|
890
|
+
#
|
866
891
|
EXTERNAL: Integer
|
867
892
|
|
893
|
+
# <!-- rdoc-file=io_buffer.c -->
|
894
|
+
# Refers to the byte order of the host machine. See #get_value for more details.
|
895
|
+
#
|
868
896
|
HOST_ENDIAN: Integer
|
869
897
|
|
898
|
+
# <!-- rdoc-file=io_buffer.c -->
|
899
|
+
# Indicates that the memory in the buffer is owned by the buffer. See #internal?
|
900
|
+
# for more details.
|
901
|
+
#
|
870
902
|
INTERNAL: Integer
|
871
903
|
|
904
|
+
# <!-- rdoc-file=io_buffer.c -->
|
905
|
+
# Refers to little endian byte order, where the least significant byte is stored
|
906
|
+
# first. See #get_value for more details.
|
907
|
+
#
|
872
908
|
LITTLE_ENDIAN: Integer
|
873
909
|
|
910
|
+
# <!-- rdoc-file=io_buffer.c -->
|
911
|
+
# Indicates that the memory in the buffer is locked and cannot be resized or
|
912
|
+
# freed. See #locked? and #locked for more details.
|
913
|
+
#
|
874
914
|
LOCKED: Integer
|
875
915
|
|
916
|
+
# <!-- rdoc-file=io_buffer.c -->
|
917
|
+
# Indicates that the memory in the buffer is mapped by the operating system. See
|
918
|
+
# #mapped? for more details.
|
919
|
+
#
|
876
920
|
MAPPED: Integer
|
877
921
|
|
922
|
+
# <!-- rdoc-file=io_buffer.c -->
|
923
|
+
# Refers to network byte order, which is the same as big endian. See #get_value
|
924
|
+
# for more details.
|
925
|
+
#
|
878
926
|
NETWORK_ENDIAN: Integer
|
879
927
|
|
928
|
+
# <!-- rdoc-file=io_buffer.c -->
|
929
|
+
# The operating system page size. Used for efficient page-aligned memory
|
930
|
+
# allocations.
|
931
|
+
#
|
880
932
|
PAGE_SIZE: Integer
|
881
933
|
|
934
|
+
# <!-- rdoc-file=io_buffer.c -->
|
935
|
+
# Indicates that the memory in the buffer is mapped privately and changes won't
|
936
|
+
# be replicated to the underlying file. See #private? for more details.
|
937
|
+
#
|
882
938
|
PRIVATE: Integer
|
883
939
|
|
940
|
+
# <!-- rdoc-file=io_buffer.c -->
|
941
|
+
# Indicates that the memory in the buffer is read only, and attempts to modify
|
942
|
+
# it will fail. See #readonly? for more details.
|
943
|
+
#
|
884
944
|
READONLY: Integer
|
885
945
|
|
946
|
+
# <!-- rdoc-file=io_buffer.c -->
|
947
|
+
# Raised when an operation would resize or re-allocate a locked buffer.
|
948
|
+
#
|
886
949
|
class LockedError < RuntimeError
|
887
950
|
end
|
888
951
|
|
952
|
+
# <!-- rdoc-file=io_buffer.c -->
|
953
|
+
# Raised when the buffer cannot be allocated for some reason, or you try to use
|
954
|
+
# a buffer that's not allocated.
|
955
|
+
#
|
889
956
|
class AllocationError < RuntimeError
|
890
957
|
end
|
891
958
|
|
959
|
+
# <!-- rdoc-file=io_buffer.c -->
|
960
|
+
# Raised when you try to write to a read-only buffer, or resize an external
|
961
|
+
# buffer.
|
962
|
+
#
|
892
963
|
class AccessError < RuntimeError
|
893
964
|
end
|
894
965
|
|
966
|
+
# <!-- rdoc-file=io_buffer.c -->
|
967
|
+
# Raised if you try to access a buffer slice which no longer references a valid
|
968
|
+
# memory range of the underlying source.
|
969
|
+
#
|
895
970
|
class InvalidatedError < RuntimeError
|
896
971
|
end
|
897
972
|
|
973
|
+
# <!-- rdoc-file=io_buffer.c -->
|
974
|
+
# Raised if the mask given to a binary operation is invalid, e.g. zero length or
|
975
|
+
# overlaps the target buffer.
|
976
|
+
#
|
898
977
|
class MaskError < ArgumentError
|
899
978
|
end
|
900
979
|
end
|
data/core/io.rbs
CHANGED
@@ -1532,7 +1532,8 @@ class IO < Object
|
|
1532
1532
|
#
|
1533
1533
|
# Related: IO#write.
|
1534
1534
|
#
|
1535
|
-
def read: (?
|
1535
|
+
def read: (?nil, ?string outbuf) -> String
|
1536
|
+
| (int? length, ?string outbuf) -> String?
|
1536
1537
|
|
1537
1538
|
# <!--
|
1538
1539
|
# rdoc-file=io.rb
|
@@ -2533,10 +2534,19 @@ class IO < Object
|
|
2533
2534
|
#
|
2534
2535
|
# Raises exceptions that IO.pipe and Kernel.spawn raise.
|
2535
2536
|
#
|
2536
|
-
def self.popen: (string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
|
2537
|
-
| (Hash[string, string?] env, string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
|
2538
|
-
| [X] (string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
|
2539
|
-
| [X] (Hash[string, string?] env, string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
|
2537
|
+
def self.popen: (string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
|
2538
|
+
| (Hash[string, string?] env, string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
|
2539
|
+
| [X] (string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
|
2540
|
+
| [X] (Hash[string, string?] env, string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
|
2541
|
+
|
2542
|
+
# The command can be given as:
|
2543
|
+
#
|
2544
|
+
# * Array of string `["ruby", "-v"]`, or
|
2545
|
+
# * Array of string with the first element of array `[["ruby", "RUBY"], "-v"]`
|
2546
|
+
#
|
2547
|
+
# But RBS cannot define such a type. So this is simply a union of `string` or `[String, String]`.
|
2548
|
+
#
|
2549
|
+
type cmd_array = array[string | [String, String]]
|
2540
2550
|
|
2541
2551
|
# <!--
|
2542
2552
|
# rdoc-file=io.c
|
@@ -3368,10 +3378,19 @@ IO::TRUNC: Integer
|
|
3368
3378
|
|
3369
3379
|
IO::WRONLY: Integer
|
3370
3380
|
|
3381
|
+
# <!-- rdoc-file=io.c -->
|
3382
|
+
# Readable event mask for IO#wait.
|
3383
|
+
#
|
3371
3384
|
IO::READABLE: Integer
|
3372
3385
|
|
3386
|
+
# <!-- rdoc-file=io.c -->
|
3387
|
+
# Writable event mask for IO#wait.
|
3388
|
+
#
|
3373
3389
|
IO::WRITABLE: Integer
|
3374
3390
|
|
3391
|
+
# <!-- rdoc-file=io.c -->
|
3392
|
+
# Priority event mask for IO#wait.
|
3393
|
+
#
|
3375
3394
|
IO::PRIORITY: Integer
|
3376
3395
|
|
3377
3396
|
# <!-- rdoc-file=io.c -->
|
data/core/kernel.rbs
CHANGED
@@ -445,14 +445,14 @@ module Kernel : BasicObject
|
|
445
445
|
|
446
446
|
# <!--
|
447
447
|
# rdoc-file=complex.c
|
448
|
-
# - Complex(
|
448
|
+
# - Complex(real, imag = 0, exception: true) -> complex or nil
|
449
449
|
# - Complex(s, exception: true) -> complex or nil
|
450
450
|
# -->
|
451
451
|
# Returns a new Complex object if the arguments are valid; otherwise raises an
|
452
452
|
# exception if `exception` is `true`; otherwise returns `nil`.
|
453
453
|
#
|
454
|
-
# With Numeric
|
455
|
-
# are valid.
|
454
|
+
# With Numeric arguments `real` and `imag`, returns `Complex.rect(real, imag)`
|
455
|
+
# if the arguments are valid.
|
456
456
|
#
|
457
457
|
# With string argument `s`, returns a new Complex object if the argument is
|
458
458
|
# valid; the string may have:
|
data/core/match_data.rbs
CHANGED
@@ -81,6 +81,16 @@ class MatchData
|
|
81
81
|
# m['foo'] # => "h"
|
82
82
|
# m[:bar] # => "ge"
|
83
83
|
#
|
84
|
+
# If multiple captures have the same name, returns the last matched substring.
|
85
|
+
#
|
86
|
+
# m = /(?<foo>.)(?<foo>.+)/.match("hoge")
|
87
|
+
# # => #<MatchData "hoge" foo:"h" foo:"oge">
|
88
|
+
# m[:foo] #=> "oge"
|
89
|
+
#
|
90
|
+
# m = /\W(?<foo>.+)|\w(?<foo>.+)|(?<foo>.+)/.match("hoge")
|
91
|
+
# #<MatchData "hoge" foo:nil foo:"oge" foo:nil>
|
92
|
+
# m[:foo] #=> "oge"
|
93
|
+
#
|
84
94
|
def []: (capture backref, ?nil) -> String?
|
85
95
|
| (int start, int length) -> Array[String?]
|
86
96
|
| (range[int?] range) -> Array[String?]
|
@@ -278,24 +288,24 @@ class MatchData
|
|
278
288
|
# rdoc-file=re.c
|
279
289
|
# - named_captures(symbolize_names: false) -> hash
|
280
290
|
# -->
|
281
|
-
# Returns a hash of the named captures;
|
282
|
-
#
|
291
|
+
# Returns a hash of the named captures; each key is a capture name; each value
|
292
|
+
# is its captured string or `nil`:
|
283
293
|
#
|
284
|
-
#
|
285
|
-
#
|
286
|
-
#
|
294
|
+
# m = /(?<foo>.)(.)(?<bar>.+)/.match("hoge")
|
295
|
+
# # => #<MatchData "hoge" foo:"h" bar:"ge">
|
296
|
+
# m.named_captures # => {"foo"=>"h", "bar"=>"ge"}
|
287
297
|
#
|
288
|
-
#
|
289
|
-
#
|
290
|
-
#
|
298
|
+
# m = /(?<a>.)(?<b>.)/.match("01")
|
299
|
+
# # => #<MatchData "01" a:"0" b:"1">
|
300
|
+
# m.named_captures #=> {"a" => "0", "b" => "1"}
|
291
301
|
#
|
292
|
-
#
|
293
|
-
#
|
294
|
-
#
|
302
|
+
# m = /(?<a>.)(?<b>.)?/.match("0")
|
303
|
+
# # => #<MatchData "0" a:"0" b:nil>
|
304
|
+
# m.named_captures #=> {"a" => "0", "b" => nil}
|
295
305
|
#
|
296
|
-
#
|
297
|
-
#
|
298
|
-
#
|
306
|
+
# m = /(?<a>.)(?<a>.)/.match("01")
|
307
|
+
# # => #<MatchData "01" a:"0" a:"1">
|
308
|
+
# m.named_captures #=> {"a" => "1"}
|
299
309
|
#
|
300
310
|
# If keyword argument `symbolize_names` is given a true value, the keys in the
|
301
311
|
# resulting hash are Symbols:
|
data/core/module.rbs
CHANGED
@@ -1532,21 +1532,21 @@ class Module < Object
|
|
1532
1532
|
# - mod.set_temporary_name(string) -> self
|
1533
1533
|
# - mod.set_temporary_name(nil) -> self
|
1534
1534
|
# -->
|
1535
|
-
# Sets the temporary name of the module
|
1536
|
-
# the
|
1537
|
-
#
|
1535
|
+
# Sets the temporary name of the module. This name is reflected in introspection
|
1536
|
+
# of the module and the values that are related to it, such as instances,
|
1537
|
+
# constants, and methods.
|
1538
1538
|
#
|
1539
|
-
#
|
1540
|
-
#
|
1539
|
+
# The name should be `nil` or non-empty string that is not a valid constant name
|
1540
|
+
# (to avoid confusing between permanent and temporary names).
|
1541
1541
|
#
|
1542
|
-
#
|
1543
|
-
#
|
1542
|
+
# The method can be useful to distinguish dynamically generated classes and
|
1543
|
+
# modules without assigning them to constants.
|
1544
1544
|
#
|
1545
|
-
#
|
1546
|
-
#
|
1547
|
-
#
|
1545
|
+
# If the module is given a permanent name by assigning it to a constant, the
|
1546
|
+
# temporary name is discarded. A temporary name can't be assigned to modules
|
1547
|
+
# that have a permanent name.
|
1548
1548
|
#
|
1549
|
-
# If the given name is `nil`, the module becomes anonymous.
|
1549
|
+
# If the given name is `nil`, the module becomes anonymous again.
|
1550
1550
|
#
|
1551
1551
|
# Example:
|
1552
1552
|
#
|
@@ -1559,15 +1559,20 @@ class Module < Object
|
|
1559
1559
|
# m.set_temporary_name(nil) # => #<Module:0x0000000102c68f38>
|
1560
1560
|
# m.name #=> nil
|
1561
1561
|
#
|
1562
|
-
#
|
1563
|
-
#
|
1562
|
+
# c = Class.new
|
1563
|
+
# c.set_temporary_name("MyClass(with description)")
|
1564
1564
|
#
|
1565
|
-
#
|
1566
|
-
# n::M.name #=> "fake_name::M"
|
1567
|
-
# N = n
|
1565
|
+
# c.new # => #<MyClass(with description):0x0....>
|
1568
1566
|
#
|
1569
|
-
#
|
1570
|
-
#
|
1567
|
+
# c::M = m
|
1568
|
+
# c::M.name #=> "MyClass(with description)::M"
|
1569
|
+
#
|
1570
|
+
# # Assigning to a constant replaces the name with a permanent one
|
1571
|
+
# C = c
|
1572
|
+
#
|
1573
|
+
# C.name #=> "C"
|
1574
|
+
# C::M.name #=> "C::M"
|
1575
|
+
# c.new # => #<C:0x0....>
|
1571
1576
|
#
|
1572
1577
|
def set_temporary_name: (string?) -> self
|
1573
1578
|
|
data/core/numeric.rbs
CHANGED
@@ -248,24 +248,22 @@ class Numeric
|
|
248
248
|
|
249
249
|
# <!--
|
250
250
|
# rdoc-file=complex.c
|
251
|
-
# -
|
251
|
+
# - abs2 -> real
|
252
252
|
# -->
|
253
|
-
# Returns square of self
|
253
|
+
# Returns the square of `self`.
|
254
254
|
#
|
255
255
|
def abs2: () -> Numeric
|
256
256
|
|
257
257
|
# <!-- rdoc-file=complex.c -->
|
258
|
-
# Returns
|
258
|
+
# Returns zero if `self` is positive, Math::PI otherwise.
|
259
259
|
#
|
260
260
|
def angle: () -> Numeric
|
261
261
|
|
262
262
|
# <!--
|
263
263
|
# rdoc-file=complex.c
|
264
|
-
# -
|
265
|
-
# - num.angle -> 0 or float
|
266
|
-
# - num.phase -> 0 or float
|
264
|
+
# - arg -> 0 or Math::PI
|
267
265
|
# -->
|
268
|
-
# Returns
|
266
|
+
# Returns zero if `self` is positive, Math::PI otherwise.
|
269
267
|
#
|
270
268
|
alias arg angle
|
271
269
|
|
@@ -559,15 +557,15 @@ class Numeric
|
|
559
557
|
def numerator: () -> Numeric
|
560
558
|
|
561
559
|
# <!-- rdoc-file=complex.c -->
|
562
|
-
# Returns
|
560
|
+
# Returns zero if `self` is positive, Math::PI otherwise.
|
563
561
|
#
|
564
562
|
alias phase angle
|
565
563
|
|
566
564
|
# <!--
|
567
565
|
# rdoc-file=complex.c
|
568
|
-
# -
|
566
|
+
# - polar -> array
|
569
567
|
# -->
|
570
|
-
# Returns
|
568
|
+
# Returns array `[self.abs, self.arg]`.
|
571
569
|
#
|
572
570
|
def polar: () -> [ Numeric, Numeric ]
|
573
571
|
|
@@ -605,16 +603,15 @@ class Numeric
|
|
605
603
|
def real?: () -> bool
|
606
604
|
|
607
605
|
# <!-- rdoc-file=complex.c -->
|
608
|
-
# Returns
|
606
|
+
# Returns array `[self, 0]`.
|
609
607
|
#
|
610
608
|
def rect: () -> [ Numeric, Numeric ]
|
611
609
|
|
612
610
|
# <!--
|
613
611
|
# rdoc-file=complex.c
|
614
|
-
# -
|
615
|
-
# - num.rectangular -> array
|
612
|
+
# - rect -> array
|
616
613
|
# -->
|
617
|
-
# Returns
|
614
|
+
# Returns array `[self, 0]`.
|
618
615
|
#
|
619
616
|
alias rectangular rect
|
620
617
|
|
@@ -763,9 +760,9 @@ class Numeric
|
|
763
760
|
|
764
761
|
# <!--
|
765
762
|
# rdoc-file=complex.c
|
766
|
-
# -
|
763
|
+
# - to_c -> complex
|
767
764
|
# -->
|
768
|
-
# Returns
|
765
|
+
# Returns `self` as a Complex object.
|
769
766
|
#
|
770
767
|
def to_c: () -> Complex
|
771
768
|
|