rbs 3.10.0.pre.2 → 3.10.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/c-check.yml +1 -1
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +7 -8
- data/CHANGELOG.md +60 -0
- data/core/array.rbs +52 -3
- data/core/comparable.rbs +13 -6
- data/core/complex.rbs +40 -25
- data/core/dir.rbs +2 -2
- data/core/encoding.rbs +3 -7
- data/core/enumerable.rbs +1 -1
- data/core/enumerator.rbs +43 -1
- data/core/fiber.rbs +26 -17
- data/core/file.rbs +23 -8
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +223 -32
- data/core/gc.rbs +4 -9
- data/core/hash.rbs +9 -10
- data/core/integer.rbs +104 -63
- data/core/io/buffer.rbs +21 -10
- data/core/io.rbs +8 -8
- data/core/kernel.rbs +12 -8
- data/core/method.rbs +49 -19
- data/core/module.rbs +30 -12
- data/core/numeric.rbs +17 -9
- data/core/object_space.rbs +13 -20
- data/core/pathname.rbs +2 -37
- data/core/proc.rbs +15 -16
- data/core/ractor.rbs +156 -145
- data/core/range.rbs +1 -1
- data/core/rational.rbs +56 -34
- data/core/rbs/unnamed/argf.rbs +1 -1
- data/core/regexp.rbs +3 -3
- data/core/ruby.rbs +53 -0
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +88 -66
- data/core/signal.rbs +24 -14
- data/core/string.rbs +304 -166
- data/core/symbol.rbs +13 -7
- data/core/thread.rbs +12 -13
- data/core/trace_point.rbs +7 -4
- data/lib/rbs/collection/config/lockfile_generator.rb +7 -0
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +1 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- 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 +11 -1
- data/stdlib/cgi-escape/0/escape.rbs +33 -15
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/json/0/json.rbs +1 -0
- data/stdlib/objspace/0/objspace.rbs +1 -1
- data/stdlib/openssl/0/openssl.rbs +150 -80
- data/stdlib/pathname/0/pathname.rbs +36 -0
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/stringio/0/stringio.rbs +796 -37
- data/stdlib/strscan/0/string_scanner.rbs +1 -1
- data/stdlib/tempfile/0/tempfile.rbs +2 -2
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/uri/0/generic.rbs +1 -1
- metadata +4 -2
data/core/rational.rbs
CHANGED
|
@@ -53,15 +53,16 @@ class Rational < Numeric
|
|
|
53
53
|
|
|
54
54
|
# <!--
|
|
55
55
|
# rdoc-file=rational.c
|
|
56
|
-
# -
|
|
56
|
+
# - self * other -> numeric
|
|
57
57
|
# -->
|
|
58
|
-
#
|
|
58
|
+
# Returns the numeric product of `self` and `other`:
|
|
59
59
|
#
|
|
60
|
-
# Rational(
|
|
61
|
-
# Rational(
|
|
62
|
-
# Rational(
|
|
63
|
-
# Rational(
|
|
64
|
-
# Rational(
|
|
60
|
+
# Rational(9, 8) * 4 #=> (9/2)
|
|
61
|
+
# Rational(20, 9) * 9.8 #=> 21.77777777777778
|
|
62
|
+
# Rational(9, 8) * Complex(1, 2) # => ((9/8)+(9/4)*i)
|
|
63
|
+
# Rational(2, 3) * Rational(2, 3) #=> (4/9)
|
|
64
|
+
# Rational(900) * Rational(1) #=> (900/1)
|
|
65
|
+
# Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
|
|
65
66
|
#
|
|
66
67
|
def *: (Integer) -> Rational
|
|
67
68
|
| (Rational) -> Rational
|
|
@@ -69,9 +70,9 @@ class Rational < Numeric
|
|
|
69
70
|
|
|
70
71
|
# <!--
|
|
71
72
|
# rdoc-file=rational.c
|
|
72
|
-
# -
|
|
73
|
+
# - self ** exponent -> numeric
|
|
73
74
|
# -->
|
|
74
|
-
#
|
|
75
|
+
# Returns `self` raised to the power `exponent`:
|
|
75
76
|
#
|
|
76
77
|
# Rational(2) ** Rational(3) #=> (8/1)
|
|
77
78
|
# Rational(10) ** -2 #=> (1/100)
|
|
@@ -85,15 +86,25 @@ class Rational < Numeric
|
|
|
85
86
|
|
|
86
87
|
# <!--
|
|
87
88
|
# rdoc-file=rational.c
|
|
88
|
-
# -
|
|
89
|
+
# - self + other -> numeric
|
|
89
90
|
# -->
|
|
90
|
-
#
|
|
91
|
+
# Returns the sum of `self` and `other`:
|
|
91
92
|
#
|
|
92
|
-
# Rational(2, 3)
|
|
93
|
-
# Rational(
|
|
94
|
-
# Rational(
|
|
95
|
-
#
|
|
96
|
-
# Rational(
|
|
93
|
+
# Rational(2, 3) + 0 # => (2/3)
|
|
94
|
+
# Rational(2, 3) + 1 # => (5/3)
|
|
95
|
+
# Rational(2, 3) + -1 # => (-1/3)
|
|
96
|
+
#
|
|
97
|
+
# Rational(2, 3) + Complex(1, 0) # => ((5/3)+0i)
|
|
98
|
+
#
|
|
99
|
+
# Rational(2, 3) + Rational(1, 1) # => (5/3)
|
|
100
|
+
# Rational(2, 3) + Rational(3, 2) # => (13/6)
|
|
101
|
+
# Rational(2, 3) + Rational(3.0, 2.0) # => (13/6)
|
|
102
|
+
# Rational(2, 3) + Rational(3.1, 2.1) # => (30399297484750849/14186338826217063)
|
|
103
|
+
#
|
|
104
|
+
# For a computation involving Floats, the result may be inexact (see Float#+):
|
|
105
|
+
#
|
|
106
|
+
# Rational(2, 3) + 1.0 # => 1.6666666666666665
|
|
107
|
+
# Rational(2, 3) + Complex(1.0, 0.0) # => (1.6666666666666665+0.0i)
|
|
97
108
|
#
|
|
98
109
|
def +: (Float) -> Float
|
|
99
110
|
| (Complex) -> Complex
|
|
@@ -103,9 +114,9 @@ class Rational < Numeric
|
|
|
103
114
|
|
|
104
115
|
# <!--
|
|
105
116
|
# rdoc-file=rational.c
|
|
106
|
-
# -
|
|
117
|
+
# - self - other -> numeric
|
|
107
118
|
# -->
|
|
108
|
-
#
|
|
119
|
+
# Returns the difference of `self` and `other`:
|
|
109
120
|
#
|
|
110
121
|
# Rational(2, 3) - Rational(2, 3) #=> (0/1)
|
|
111
122
|
# Rational(900) - Rational(1) #=> (899/1)
|
|
@@ -119,18 +130,20 @@ class Rational < Numeric
|
|
|
119
130
|
|
|
120
131
|
# <!--
|
|
121
132
|
# rdoc-file=rational.c
|
|
122
|
-
# - -
|
|
133
|
+
# - -self -> rational
|
|
123
134
|
# -->
|
|
124
|
-
#
|
|
135
|
+
# Returns `self`, negated:
|
|
136
|
+
#
|
|
137
|
+
# -(1/3r) # => (-1/3)
|
|
138
|
+
# -(-1/3r) # => (1/3)
|
|
125
139
|
#
|
|
126
140
|
def -@: () -> Rational
|
|
127
141
|
|
|
128
142
|
# <!--
|
|
129
143
|
# rdoc-file=rational.c
|
|
130
|
-
# -
|
|
131
|
-
# - rat.quo(numeric) -> numeric
|
|
144
|
+
# - self / other -> numeric
|
|
132
145
|
# -->
|
|
133
|
-
#
|
|
146
|
+
# Returns the quotient of `self` and `other`:
|
|
134
147
|
#
|
|
135
148
|
# Rational(2, 3) / Rational(2, 3) #=> (1/1)
|
|
136
149
|
# Rational(900) / Rational(1) #=> (900/1)
|
|
@@ -144,20 +157,29 @@ class Rational < Numeric
|
|
|
144
157
|
|
|
145
158
|
# <!--
|
|
146
159
|
# rdoc-file=rational.c
|
|
147
|
-
# -
|
|
160
|
+
# - self <=> other -> -1, 0, 1, or nil
|
|
148
161
|
# -->
|
|
149
|
-
#
|
|
150
|
-
#
|
|
162
|
+
# Compares `self` and `other`.
|
|
163
|
+
#
|
|
164
|
+
# Returns:
|
|
165
|
+
#
|
|
166
|
+
# * `-1`, if `self` is less than `other`.
|
|
167
|
+
# * `0`, if the two values are the same.
|
|
168
|
+
# * `1`, if `self` is greater than `other`.
|
|
169
|
+
# * `nil`, if the two values are incomparable.
|
|
151
170
|
#
|
|
152
|
-
#
|
|
171
|
+
# Examples:
|
|
153
172
|
#
|
|
154
|
-
# Rational(2, 3) <=> Rational(
|
|
155
|
-
# Rational(
|
|
156
|
-
# Rational(2,
|
|
157
|
-
# Rational(
|
|
158
|
-
# Rational(
|
|
173
|
+
# Rational(2, 3) <=> Rational(4, 3) # => -1
|
|
174
|
+
# Rational(2, 1) <=> Rational(2, 1) # => 0
|
|
175
|
+
# Rational(2, 1) <=> 2 # => 0
|
|
176
|
+
# Rational(2, 1) <=> 2.0 # => 0
|
|
177
|
+
# Rational(2, 1) <=> Complex(2, 0) # => 0
|
|
178
|
+
# Rational(4, 3) <=> Rational(2, 3) # => 1
|
|
179
|
+
# Rational(4, 3) <=> :foo # => nil
|
|
159
180
|
#
|
|
160
|
-
#
|
|
181
|
+
# Class Rational includes module Comparable, each of whose methods uses
|
|
182
|
+
# Rational#<=> for comparison.
|
|
161
183
|
#
|
|
162
184
|
def <=>: (Integer | Rational) -> Integer
|
|
163
185
|
| (untyped) -> Integer?
|
|
@@ -364,7 +386,7 @@ class Rational < Numeric
|
|
|
364
386
|
def positive?: () -> bool
|
|
365
387
|
|
|
366
388
|
# <!-- rdoc-file=rational.c -->
|
|
367
|
-
#
|
|
389
|
+
# Returns the quotient of `self` and `other`:
|
|
368
390
|
#
|
|
369
391
|
# Rational(2, 3) / Rational(2, 3) #=> (1/1)
|
|
370
392
|
# Rational(900) / Rational(1) #=> (900/1)
|
data/core/rbs/unnamed/argf.rbs
CHANGED
|
@@ -836,7 +836,7 @@ module RBS
|
|
|
836
836
|
# Formats and writes `objects` to the stream.
|
|
837
837
|
#
|
|
838
838
|
# For details on `format_string`, see [Format
|
|
839
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
839
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
840
840
|
#
|
|
841
841
|
%a{annotate:rdoc:copy:ARGF#printf}
|
|
842
842
|
def printf: (String format_string, *untyped args) -> nil
|
data/core/regexp.rbs
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
# most such methods accept an argument that may be either a string or the
|
|
40
40
|
# (much more powerful) regexp.
|
|
41
41
|
#
|
|
42
|
-
# See [Regexp Methods](rdoc-ref:regexp/methods.rdoc).
|
|
42
|
+
# See [Regexp Methods](rdoc-ref:language/regexp/methods.rdoc).
|
|
43
43
|
#
|
|
44
44
|
# ## Regexp Objects
|
|
45
45
|
#
|
|
@@ -821,8 +821,8 @@
|
|
|
821
821
|
# /\P{Alpha}/.match('1') # => #<MatchData "1">
|
|
822
822
|
# /\P{Alpha}/.match('a') # => nil
|
|
823
823
|
#
|
|
824
|
-
# See [Unicode Properties](rdoc-ref:regexp/unicode_properties.rdoc) for
|
|
825
|
-
# based on the numerous properties.
|
|
824
|
+
# See [Unicode Properties](rdoc-ref:language/regexp/unicode_properties.rdoc) for
|
|
825
|
+
# regexps based on the numerous properties.
|
|
826
826
|
#
|
|
827
827
|
# Some commonly-used properties correspond to POSIX bracket expressions:
|
|
828
828
|
#
|
data/core/ruby.rbs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# <!-- rdoc-file=version.c -->
|
|
2
|
+
# The [Ruby](rdoc-ref:Ruby) module that contains portable information among
|
|
3
|
+
# implementations.
|
|
4
|
+
#
|
|
5
|
+
# The constants defined here are aliased in the toplevel with `RUBY_` prefix.
|
|
6
|
+
#
|
|
7
|
+
module Ruby
|
|
8
|
+
# <!-- rdoc-file=version.c -->
|
|
9
|
+
# The copyright string for ruby
|
|
10
|
+
#
|
|
11
|
+
COPYRIGHT: ::String
|
|
12
|
+
|
|
13
|
+
# <!-- rdoc-file=version.c -->
|
|
14
|
+
# The full ruby version string, like `ruby -v` prints
|
|
15
|
+
#
|
|
16
|
+
DESCRIPTION: ::String
|
|
17
|
+
|
|
18
|
+
# <!-- rdoc-file=version.c -->
|
|
19
|
+
# The engine or interpreter this ruby uses.
|
|
20
|
+
#
|
|
21
|
+
ENGINE: ::String
|
|
22
|
+
|
|
23
|
+
# <!-- rdoc-file=version.c -->
|
|
24
|
+
# The version of the engine or interpreter this ruby uses.
|
|
25
|
+
#
|
|
26
|
+
ENGINE_VERSION: ::String
|
|
27
|
+
|
|
28
|
+
# <!-- rdoc-file=version.c -->
|
|
29
|
+
# The patchlevel for this ruby. If this is a development build of ruby the
|
|
30
|
+
# patchlevel will be -1
|
|
31
|
+
#
|
|
32
|
+
PATCHLEVEL: ::Integer
|
|
33
|
+
|
|
34
|
+
# <!-- rdoc-file=version.c -->
|
|
35
|
+
# The platform for this ruby
|
|
36
|
+
#
|
|
37
|
+
PLATFORM: ::String
|
|
38
|
+
|
|
39
|
+
# <!-- rdoc-file=version.c -->
|
|
40
|
+
# The date this ruby was released
|
|
41
|
+
#
|
|
42
|
+
RELEASE_DATE: ::String
|
|
43
|
+
|
|
44
|
+
# <!-- rdoc-file=version.c -->
|
|
45
|
+
# The GIT commit hash for this ruby.
|
|
46
|
+
#
|
|
47
|
+
REVISION: ::String
|
|
48
|
+
|
|
49
|
+
# <!-- rdoc-file=version.c -->
|
|
50
|
+
# The running version of ruby
|
|
51
|
+
#
|
|
52
|
+
VERSION: ::String
|
|
53
|
+
end
|
data/core/rubygems/version.rbs
CHANGED
|
@@ -180,7 +180,6 @@ module Gem
|
|
|
180
180
|
#
|
|
181
181
|
# ver1 = Version.create('1.3.17') # -> (Version object)
|
|
182
182
|
# ver2 = Version.create(ver1) # -> (ver1)
|
|
183
|
-
# ver3 = Version.create(nil) # -> nil
|
|
184
183
|
#
|
|
185
184
|
def self.create: (_ToS | Version input) -> instance
|
|
186
185
|
| (nil input) -> nil
|
|
@@ -199,8 +198,8 @@ module Gem
|
|
|
199
198
|
# - <=>(other)
|
|
200
199
|
# -->
|
|
201
200
|
# Compares this version with `other` returning -1, 0, or 1 if the other version
|
|
202
|
-
# is larger, the same, or smaller than this one.
|
|
203
|
-
#
|
|
201
|
+
# is larger, the same, or smaller than this one. `other` must be an instance of
|
|
202
|
+
# Gem::Version, comparing with other types may raise an exception.
|
|
204
203
|
#
|
|
205
204
|
def <=>: (untyped other) -> Integer?
|
|
206
205
|
|
data/core/set.rbs
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
# <!-- rdoc-file=set.c -->
|
|
2
|
-
# Copyright (c) 2002-2024 Akinori MUSHA <knu@iDaemons.org>
|
|
3
|
-
#
|
|
4
|
-
# Documentation by Akinori MUSHA and Gavin Sinclair.
|
|
5
|
-
#
|
|
6
|
-
# All rights reserved. You can redistribute and/or modify it under the same
|
|
7
|
-
# terms as Ruby.
|
|
8
|
-
#
|
|
9
2
|
# The Set class implements a collection of unordered values with no duplicates.
|
|
10
3
|
# It is a hybrid of Array's intuitive inter-operation facilities and Hash's fast
|
|
11
4
|
# lookup.
|
|
12
5
|
#
|
|
13
|
-
# Set is easy to use with Enumerable objects (implementing
|
|
6
|
+
# Set is easy to use with Enumerable objects (implementing #each). Most of the
|
|
14
7
|
# initializer methods and binary operators accept generic Enumerable objects
|
|
15
8
|
# besides sets and arrays. An Enumerable object can be converted to Set using
|
|
16
9
|
# the `to_set` method.
|
|
@@ -36,11 +29,11 @@
|
|
|
36
29
|
#
|
|
37
30
|
# ## Example
|
|
38
31
|
#
|
|
39
|
-
# s1 = Set[1, 2] #=>
|
|
40
|
-
# s2 = [1, 2].to_set #=>
|
|
32
|
+
# s1 = Set[1, 2] #=> Set[1, 2]
|
|
33
|
+
# s2 = [1, 2].to_set #=> Set[1, 2]
|
|
41
34
|
# s1 == s2 #=> true
|
|
42
|
-
# s1.add("foo") #=>
|
|
43
|
-
# s1.merge([2, 6]) #=>
|
|
35
|
+
# s1.add("foo") #=> Set[1, 2, "foo"]
|
|
36
|
+
# s1.merge([2, 6]) #=> Set[1, 2, "foo", 6]
|
|
44
37
|
# s1.subset?(s2) #=> false
|
|
45
38
|
# s2.subset?(s1) #=> true
|
|
46
39
|
#
|
|
@@ -48,9 +41,39 @@
|
|
|
48
41
|
#
|
|
49
42
|
# * Akinori MUSHA <knu@iDaemons.org> (current maintainer)
|
|
50
43
|
#
|
|
51
|
-
# ##
|
|
44
|
+
# ## Inheriting from Set
|
|
45
|
+
#
|
|
46
|
+
# Before Ruby 4.0 (released December 2025), Set had a different, less efficient
|
|
47
|
+
# implementation. It was reimplemented in C, and the behavior of some of the
|
|
48
|
+
# core methods were adjusted.
|
|
49
|
+
#
|
|
50
|
+
# To keep backward compatibility, when a class is inherited from Set, additional
|
|
51
|
+
# module `Set::SubclassCompatible` is included, which makes the inherited class
|
|
52
|
+
# behavior, as well as internal method names, closer to what it was before Ruby
|
|
53
|
+
# 4.0.
|
|
54
|
+
#
|
|
55
|
+
# It can be easily seen, for example, in the #inspect method behavior:
|
|
56
|
+
#
|
|
57
|
+
# p Set[1, 2, 3]
|
|
58
|
+
# # prints "Set[1, 2, 3]"
|
|
59
|
+
#
|
|
60
|
+
# class MySet < Set
|
|
61
|
+
# end
|
|
62
|
+
# p MySet[1, 2, 3]
|
|
63
|
+
# # prints "#<MySet: {1, 2, 3}>", like it was in Ruby 3.4
|
|
64
|
+
#
|
|
65
|
+
# For new code, if backward compatibility is not necessary, it is recommended to
|
|
66
|
+
# instead inherit from `Set::CoreSet`, which avoids including the
|
|
67
|
+
# "compatibility" layer:
|
|
68
|
+
#
|
|
69
|
+
# class MyCoreSet < Set::CoreSet
|
|
70
|
+
# end
|
|
71
|
+
# p MyCoreSet[1, 2, 3]
|
|
72
|
+
# # prints "MyCoreSet[1, 2, 3]"
|
|
73
|
+
#
|
|
74
|
+
# ## Set's methods
|
|
52
75
|
#
|
|
53
|
-
#
|
|
76
|
+
# First, what's elsewhere. Class Set:
|
|
54
77
|
#
|
|
55
78
|
# * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
|
|
56
79
|
# * Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which
|
|
@@ -61,16 +84,15 @@
|
|
|
61
84
|
#
|
|
62
85
|
# Here, class Set provides methods that are useful for:
|
|
63
86
|
#
|
|
64
|
-
# * [Creating an Array](rdoc-ref:Array@Methods+for+Creating+an+Array)
|
|
65
87
|
# * [Creating a Set](rdoc-ref:Set@Methods+for+Creating+a+Set)
|
|
66
88
|
# * [Set Operations](rdoc-ref:Set@Methods+for+Set+Operations)
|
|
67
|
-
# * [Comparing](rdoc-ref:
|
|
68
|
-
# * [Querying](rdoc-ref:
|
|
69
|
-
# * [Assigning](rdoc-ref:
|
|
70
|
-
# * [Deleting](rdoc-ref:
|
|
71
|
-
# * [Converting](rdoc-ref:
|
|
72
|
-
# * [Iterating](rdoc-ref:
|
|
73
|
-
# * [And more....](rdoc-ref:
|
|
89
|
+
# * [Comparing](rdoc-ref:Set@Methods+for+Comparing)
|
|
90
|
+
# * [Querying](rdoc-ref:Set@Methods+for+Querying)
|
|
91
|
+
# * [Assigning](rdoc-ref:Set@Methods+for+Assigning)
|
|
92
|
+
# * [Deleting](rdoc-ref:Set@Methods+for+Deleting)
|
|
93
|
+
# * [Converting](rdoc-ref:Set@Methods+for+Converting)
|
|
94
|
+
# * [Iterating](rdoc-ref:Set@Methods+for+Iterating)
|
|
95
|
+
# * [And more....](rdoc-ref:Set@Other+Methods)
|
|
74
96
|
#
|
|
75
97
|
# ### Methods for Creating a Set
|
|
76
98
|
#
|
|
@@ -183,11 +205,11 @@ class Set[unchecked out A]
|
|
|
183
205
|
#
|
|
184
206
|
# If a block is given, the elements of enum are preprocessed by the given block.
|
|
185
207
|
#
|
|
186
|
-
# Set.new([1, 2]) #=>
|
|
187
|
-
# Set.new([1, 2, 1]) #=>
|
|
188
|
-
# Set.new([1, 'c', :s]) #=>
|
|
189
|
-
# Set.new(1..5) #=>
|
|
190
|
-
# Set.new([1, 2, 3]) { |x| x * x } #=>
|
|
208
|
+
# Set.new([1, 2]) #=> Set[1, 2]
|
|
209
|
+
# Set.new([1, 2, 1]) #=> Set[1, 2]
|
|
210
|
+
# Set.new([1, 'c', :s]) #=> Set[1, "c", :s]
|
|
211
|
+
# Set.new(1..5) #=> Set[1, 2, 3, 4, 5]
|
|
212
|
+
# Set.new([1, 2, 3]) { |x| x * x } #=> Set[1, 4, 9]
|
|
191
213
|
#
|
|
192
214
|
def initialize: (_Each[A]) -> untyped
|
|
193
215
|
| [X] (_Each[X]) { (X) -> A } -> untyped
|
|
@@ -208,8 +230,8 @@ class Set[unchecked out A]
|
|
|
208
230
|
# Returns a new set containing elements common to the set and the given
|
|
209
231
|
# enumerable object.
|
|
210
232
|
#
|
|
211
|
-
# Set[1, 3, 5] & Set[3, 2, 1] #=>
|
|
212
|
-
# Set['a', 'b', 'z'] & ['a', 'b', 'c'] #=>
|
|
233
|
+
# Set[1, 3, 5] & Set[3, 2, 1] #=> Set[3, 1]
|
|
234
|
+
# Set['a', 'b', 'z'] & ['a', 'b', 'c'] #=> Set["a", "b"]
|
|
213
235
|
#
|
|
214
236
|
def &: (_Each[A]) -> self
|
|
215
237
|
|
|
@@ -217,8 +239,8 @@ class Set[unchecked out A]
|
|
|
217
239
|
# Returns a new set containing elements common to the set and the given
|
|
218
240
|
# enumerable object.
|
|
219
241
|
#
|
|
220
|
-
# Set[1, 3, 5] & Set[3, 2, 1] #=>
|
|
221
|
-
# Set['a', 'b', 'z'] & ['a', 'b', 'c'] #=>
|
|
242
|
+
# Set[1, 3, 5] & Set[3, 2, 1] #=> Set[3, 1]
|
|
243
|
+
# Set['a', 'b', 'z'] & ['a', 'b', 'c'] #=> Set["a", "b"]
|
|
222
244
|
#
|
|
223
245
|
alias intersection &
|
|
224
246
|
|
|
@@ -229,8 +251,8 @@ class Set[unchecked out A]
|
|
|
229
251
|
# Returns a new set built by merging the set and the elements of the given
|
|
230
252
|
# enumerable object.
|
|
231
253
|
#
|
|
232
|
-
# Set[1, 2, 3] | Set[2, 4, 5] #=>
|
|
233
|
-
# Set[1, 5, 'z'] | (1..6) #=>
|
|
254
|
+
# Set[1, 2, 3] | Set[2, 4, 5] #=> Set[1, 2, 3, 4, 5]
|
|
255
|
+
# Set[1, 5, 'z'] | (1..6) #=> Set[1, 5, "z", 2, 3, 4, 6]
|
|
234
256
|
#
|
|
235
257
|
def |: (_Each[A]) -> self
|
|
236
258
|
|
|
@@ -238,8 +260,8 @@ class Set[unchecked out A]
|
|
|
238
260
|
# Returns a new set built by merging the set and the elements of the given
|
|
239
261
|
# enumerable object.
|
|
240
262
|
#
|
|
241
|
-
# Set[1, 2, 3] | Set[2, 4, 5] #=>
|
|
242
|
-
# Set[1, 5, 'z'] | (1..6) #=>
|
|
263
|
+
# Set[1, 2, 3] | Set[2, 4, 5] #=> Set[1, 2, 3, 4, 5]
|
|
264
|
+
# Set[1, 5, 'z'] | (1..6) #=> Set[1, 5, "z", 2, 3, 4, 6]
|
|
243
265
|
#
|
|
244
266
|
alias union |
|
|
245
267
|
|
|
@@ -247,8 +269,8 @@ class Set[unchecked out A]
|
|
|
247
269
|
# Returns a new set built by merging the set and the elements of the given
|
|
248
270
|
# enumerable object.
|
|
249
271
|
#
|
|
250
|
-
# Set[1, 2, 3] | Set[2, 4, 5] #=>
|
|
251
|
-
# Set[1, 5, 'z'] | (1..6) #=>
|
|
272
|
+
# Set[1, 2, 3] | Set[2, 4, 5] #=> Set[1, 2, 3, 4, 5]
|
|
273
|
+
# Set[1, 5, 'z'] | (1..6) #=> Set[1, 5, "z", 2, 3, 4, 6]
|
|
252
274
|
#
|
|
253
275
|
alias + |
|
|
254
276
|
|
|
@@ -259,8 +281,8 @@ class Set[unchecked out A]
|
|
|
259
281
|
# Returns a new set built by duplicating the set, removing every element that
|
|
260
282
|
# appears in the given enumerable object.
|
|
261
283
|
#
|
|
262
|
-
# Set[1, 3, 5] - Set[1, 5] #=>
|
|
263
|
-
# Set['a', 'b', 'z'] - ['a', 'c'] #=>
|
|
284
|
+
# Set[1, 3, 5] - Set[1, 5] #=> Set[3]
|
|
285
|
+
# Set['a', 'b', 'z'] - ['a', 'c'] #=> Set["b", "z"]
|
|
264
286
|
#
|
|
265
287
|
def -: (_Each[A]) -> self
|
|
266
288
|
|
|
@@ -268,8 +290,8 @@ class Set[unchecked out A]
|
|
|
268
290
|
# Returns a new set built by duplicating the set, removing every element that
|
|
269
291
|
# appears in the given enumerable object.
|
|
270
292
|
#
|
|
271
|
-
# Set[1, 3, 5] - Set[1, 5] #=>
|
|
272
|
-
# Set['a', 'b', 'z'] - ['a', 'c'] #=>
|
|
293
|
+
# Set[1, 3, 5] - Set[1, 5] #=> Set[3]
|
|
294
|
+
# Set['a', 'b', 'z'] - ['a', 'c'] #=> Set["b", "z"]
|
|
273
295
|
#
|
|
274
296
|
alias difference -
|
|
275
297
|
|
|
@@ -277,22 +299,22 @@ class Set[unchecked out A]
|
|
|
277
299
|
# rdoc-file=set.c
|
|
278
300
|
# - add(obj) -> self
|
|
279
301
|
# -->
|
|
280
|
-
# Adds the given object to the set and returns self.
|
|
302
|
+
# Adds the given object to the set and returns self. Use Set#merge to add many
|
|
281
303
|
# elements at once.
|
|
282
304
|
#
|
|
283
|
-
# Set[1, 2].add(3) #=>
|
|
284
|
-
# Set[1, 2].add([3, 4]) #=>
|
|
285
|
-
# Set[1, 2].add(2) #=>
|
|
305
|
+
# Set[1, 2].add(3) #=> Set[1, 2, 3]
|
|
306
|
+
# Set[1, 2].add([3, 4]) #=> Set[1, 2, [3, 4]]
|
|
307
|
+
# Set[1, 2].add(2) #=> Set[1, 2]
|
|
286
308
|
#
|
|
287
309
|
def add: (A) -> self
|
|
288
310
|
|
|
289
311
|
# <!-- rdoc-file=set.c -->
|
|
290
|
-
# Adds the given object to the set and returns self.
|
|
312
|
+
# Adds the given object to the set and returns self. Use Set#merge to add many
|
|
291
313
|
# elements at once.
|
|
292
314
|
#
|
|
293
|
-
# Set[1, 2].add(3) #=>
|
|
294
|
-
# Set[1, 2].add([3, 4]) #=>
|
|
295
|
-
# Set[1, 2].add(2) #=>
|
|
315
|
+
# Set[1, 2].add(3) #=> Set[1, 2, 3]
|
|
316
|
+
# Set[1, 2].add([3, 4]) #=> Set[1, 2, [3, 4]]
|
|
317
|
+
# Set[1, 2].add(2) #=> Set[1, 2]
|
|
296
318
|
#
|
|
297
319
|
alias << add
|
|
298
320
|
|
|
@@ -303,8 +325,8 @@ class Set[unchecked out A]
|
|
|
303
325
|
# Adds the given object to the set and returns self. If the object is already in
|
|
304
326
|
# the set, returns nil.
|
|
305
327
|
#
|
|
306
|
-
# Set[1, 2].add?(3) #=>
|
|
307
|
-
# Set[1, 2].add?([3, 4]) #=>
|
|
328
|
+
# Set[1, 2].add?(3) #=> Set[1, 2, 3]
|
|
329
|
+
# Set[1, 2].add?([3, 4]) #=> Set[1, 2, [3, 4]]
|
|
308
330
|
# Set[1, 2].add?(2) #=> nil
|
|
309
331
|
#
|
|
310
332
|
def add?: (A) -> self?
|
|
@@ -366,8 +388,8 @@ class Set[unchecked out A]
|
|
|
366
388
|
# enumerable object. `(set ^ enum)` is equivalent to `((set | enum) - (set &
|
|
367
389
|
# enum))`.
|
|
368
390
|
#
|
|
369
|
-
# Set[1, 2] ^ Set[2, 3] #=>
|
|
370
|
-
# Set[1, 'b', 'c'] ^ ['b', 'd'] #=>
|
|
391
|
+
# Set[1, 2] ^ Set[2, 3] #=> Set[3, 1]
|
|
392
|
+
# Set[1, 'b', 'c'] ^ ['b', 'd'] #=> Set["d", 1, "c"]
|
|
371
393
|
#
|
|
372
394
|
def ^: (_Each[A]) -> self
|
|
373
395
|
|
|
@@ -382,9 +404,9 @@ class Set[unchecked out A]
|
|
|
382
404
|
#
|
|
383
405
|
# files = Set.new(Dir.glob("*.rb"))
|
|
384
406
|
# hash = files.classify { |f| File.mtime(f).year }
|
|
385
|
-
# hash #=> {2000 =>
|
|
386
|
-
# # 2001 =>
|
|
387
|
-
# # 2002 =>
|
|
407
|
+
# hash #=> {2000 => Set["a.rb", "b.rb"],
|
|
408
|
+
# # 2001 => Set["c.rb", "d.rb", "e.rb"],
|
|
409
|
+
# # 2002 => Set["f.rb"]}
|
|
388
410
|
#
|
|
389
411
|
# Returns an enumerator if no block is given.
|
|
390
412
|
#
|
|
@@ -396,9 +418,9 @@ class Set[unchecked out A]
|
|
|
396
418
|
# -->
|
|
397
419
|
# Removes all elements and returns self.
|
|
398
420
|
#
|
|
399
|
-
# set = Set[1, 'c', :s] #=>
|
|
400
|
-
# set.clear #=>
|
|
401
|
-
# set #=>
|
|
421
|
+
# set = Set[1, 'c', :s] #=> Set[1, "c", :s]
|
|
422
|
+
# set.clear #=> Set[]
|
|
423
|
+
# set #=> Set[]
|
|
402
424
|
#
|
|
403
425
|
def clear: () -> self
|
|
404
426
|
|
|
@@ -502,10 +524,10 @@ class Set[unchecked out A]
|
|
|
502
524
|
#
|
|
503
525
|
# numbers = Set[1, 3, 4, 6, 9, 10, 11]
|
|
504
526
|
# set = numbers.divide { |i,j| (i - j).abs == 1 }
|
|
505
|
-
# set #=>
|
|
506
|
-
# #
|
|
507
|
-
# #
|
|
508
|
-
# #
|
|
527
|
+
# set #=> Set[Set[1],
|
|
528
|
+
# # Set[3, 4],
|
|
529
|
+
# # Set[6],
|
|
530
|
+
# # Set[9, 10, 11]]
|
|
509
531
|
#
|
|
510
532
|
# Returns an enumerator if no block is given.
|
|
511
533
|
#
|
|
@@ -654,9 +676,9 @@ class Set[unchecked out A]
|
|
|
654
676
|
# Replaces the contents of the set with the contents of the given enumerable
|
|
655
677
|
# object and returns self.
|
|
656
678
|
#
|
|
657
|
-
# set = Set[1, 'c', :s] #=>
|
|
658
|
-
# set.replace([1, 2]) #=>
|
|
659
|
-
# set #=>
|
|
679
|
+
# set = Set[1, 'c', :s] #=> Set[1, "c", :s]
|
|
680
|
+
# set.replace([1, 2]) #=> Set[1, 2]
|
|
681
|
+
# set #=> Set[1, 2]
|
|
660
682
|
#
|
|
661
683
|
def replace: (_Each[A]) -> self
|
|
662
684
|
|
data/core/signal.rbs
CHANGED
|
@@ -65,26 +65,36 @@ module Signal
|
|
|
65
65
|
|
|
66
66
|
# <!--
|
|
67
67
|
# rdoc-file=signal.c
|
|
68
|
-
# - Signal.trap(
|
|
69
|
-
# - Signal.trap(
|
|
68
|
+
# - Signal.trap(signal, command) -> obj
|
|
69
|
+
# - Signal.trap(signal) { ... } -> obj
|
|
70
70
|
# -->
|
|
71
|
-
# Specifies the handling of signals.
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
# command
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
#
|
|
71
|
+
# Specifies the handling of signals. Returns the previous handler for the given
|
|
72
|
+
# signal.
|
|
73
|
+
#
|
|
74
|
+
# Argument `signal` is a signal name (a string or symbol such as `SIGALRM` or
|
|
75
|
+
# `SIGUSR1`) or an integer signal number. When `signal` is a string or symbol,
|
|
76
|
+
# the leading characters `SIG` may be omitted.
|
|
77
|
+
#
|
|
78
|
+
# Argument `command` or block provided specifies code to be run when the signal
|
|
79
|
+
# is raised.
|
|
80
|
+
#
|
|
81
|
+
# Argument `command` may also be a string or symbol with the following special
|
|
82
|
+
# values:
|
|
83
|
+
#
|
|
84
|
+
# * `IGNORE`, `SIG_IGN`: the signal will be ignored.
|
|
85
|
+
# * `DEFAULT`, `SIG_DFL`: Ruby's default handler will be invoked.
|
|
86
|
+
# * `EXIT`: the process will be terminated by the signal.
|
|
87
|
+
# * `SYSTEM_DEFAULT`: the operating system's default handler will be invoked.
|
|
88
|
+
#
|
|
89
|
+
# The special signal name `EXIT` or signal number zero will be invoked just
|
|
90
|
+
# prior to program termination:
|
|
82
91
|
#
|
|
83
92
|
# Signal.trap(0, proc { puts "Terminating: #{$$}" })
|
|
84
93
|
# Signal.trap("CLD") { puts "Child died" }
|
|
85
94
|
# fork && Process.wait
|
|
86
95
|
#
|
|
87
|
-
#
|
|
96
|
+
# Outputs:
|
|
97
|
+
#
|
|
88
98
|
# Terminating: 27461
|
|
89
99
|
# Child died
|
|
90
100
|
# Terminating: 27460
|