rbs 3.0.0.dev.2 → 3.0.0.dev.3
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 +2 -1
- data/.github/workflows/ruby.yml +4 -0
- data/Gemfile.lock +11 -11
- data/Rakefile +2 -2
- data/Steepfile +1 -1
- data/core/array.rbs +573 -423
- data/core/basic_object.rbs +11 -39
- data/core/binding.rbs +1 -1
- data/core/builtin.rbs +8 -0
- data/core/class.rbs +37 -0
- data/core/comparable.rbs +7 -18
- data/core/complex.rbs +2 -2
- data/core/data.rbs +419 -0
- data/core/dir.rbs +52 -104
- data/core/encoding.rbs +22 -181
- data/core/enumerable.rbs +212 -175
- data/core/enumerator/product.rbs +96 -0
- data/core/enumerator.rbs +57 -8
- data/core/errors.rbs +8 -2
- data/core/exception.rbs +41 -0
- data/core/fiber.rbs +95 -12
- data/core/file.rbs +840 -275
- data/core/file_test.rbs +34 -19
- data/core/float.rbs +40 -96
- data/core/gc.rbs +15 -3
- data/core/hash.rbs +113 -175
- data/core/integer.rbs +85 -145
- data/core/io/buffer.rbs +187 -60
- data/core/io/wait.rbs +28 -16
- data/core/io.rbs +1859 -1389
- data/core/kernel.rbs +525 -961
- data/core/match_data.rbs +306 -142
- data/core/math.rbs +506 -234
- data/core/method.rbs +0 -24
- data/core/module.rbs +110 -17
- data/core/nil_class.rbs +2 -0
- data/core/numeric.rbs +76 -144
- data/core/object.rbs +88 -212
- data/core/proc.rbs +17 -5
- data/core/process.rbs +22 -5
- data/core/ractor.rbs +1 -1
- data/core/random.rbs +20 -3
- data/core/range.rbs +91 -89
- data/core/rational.rbs +2 -3
- data/core/rbs/unnamed/argf.rbs +177 -120
- data/core/rbs/unnamed/env_class.rbs +89 -163
- data/core/rbs/unnamed/random.rbs +36 -12
- data/core/refinement.rbs +8 -0
- data/core/regexp.rbs +462 -272
- data/core/ruby_vm.rbs +210 -0
- data/{stdlib/set/0 → core}/set.rbs +43 -47
- data/core/string.rbs +1403 -1332
- data/core/string_io.rbs +191 -107
- data/core/struct.rbs +67 -63
- data/core/symbol.rbs +187 -201
- data/core/thread.rbs +40 -35
- data/core/time.rbs +902 -826
- data/core/trace_point.rbs +55 -6
- data/core/unbound_method.rbs +48 -24
- data/docs/collection.md +4 -0
- data/docs/syntax.md +55 -0
- data/ext/rbs_extension/parser.c +5 -6
- data/lib/rbs/cli.rb +6 -1
- data/lib/rbs/collection/cleaner.rb +8 -1
- data/lib/rbs/collection/config/lockfile.rb +3 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +16 -14
- data/lib/rbs/collection/config.rb +1 -1
- data/lib/rbs/collection/sources/git.rb +9 -2
- data/lib/rbs/collection/sources/local.rb +79 -0
- data/lib/rbs/collection/sources.rb +8 -1
- data/lib/rbs/environment.rb +6 -5
- data/lib/rbs/environment_loader.rb +3 -2
- data/lib/rbs/errors.rb +18 -0
- data/lib/rbs/locator.rb +26 -7
- data/lib/rbs/sorter.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/sig/collection/sources.rbs +32 -3
- data/sig/environment.rbs +2 -3
- data/sig/locator.rbs +14 -2
- data/sig/shims/{abstract_syntax_tree.rbs → _abstract_syntax_tree.rbs} +0 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -13
- data/stdlib/cgi/0/core.rbs +16 -0
- data/stdlib/coverage/0/coverage.rbs +50 -8
- data/stdlib/csv/0/csv.rbs +1 -1
- data/stdlib/date/0/date.rbs +856 -726
- data/stdlib/date/0/date_time.rbs +83 -210
- data/stdlib/erb/0/erb.rbs +13 -36
- data/stdlib/etc/0/etc.rbs +127 -20
- data/stdlib/fileutils/0/fileutils.rbs +1290 -381
- data/stdlib/logger/0/logger.rbs +466 -316
- data/stdlib/net-http/0/net-http.rbs +2211 -534
- data/stdlib/nkf/0/nkf.rbs +5 -5
- data/stdlib/objspace/0/objspace.rbs +31 -14
- data/stdlib/openssl/0/openssl.rbs +11 -7
- data/stdlib/optparse/0/optparse.rbs +20 -17
- data/stdlib/pathname/0/pathname.rbs +21 -4
- data/stdlib/pstore/0/pstore.rbs +378 -154
- data/stdlib/pty/0/pty.rbs +24 -8
- data/stdlib/ripper/0/ripper.rbs +1650 -0
- data/stdlib/socket/0/addrinfo.rbs +9 -15
- data/stdlib/socket/0/socket.rbs +36 -3
- data/stdlib/strscan/0/string_scanner.rbs +7 -5
- data/stdlib/tempfile/0/tempfile.rbs +104 -44
- data/stdlib/time/0/time.rbs +2 -2
- data/stdlib/uri/0/file.rbs +5 -0
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/yaml/0/yaml.rbs +2 -2
- data/stdlib/zlib/0/zlib.rbs +1 -1
- metadata +8 -6
- data/core/deprecated.rbs +0 -9
- data/sig/shims/ripper.rbs +0 -8
data/core/struct.rbs
CHANGED
@@ -42,89 +42,75 @@
|
|
42
42
|
#
|
43
43
|
# First, what's elsewhere. Class Struct:
|
44
44
|
#
|
45
|
-
# * Inherits from [class
|
46
|
-
#
|
47
|
-
# * Includes [module
|
48
|
-
# Enumerable](Enumerable.html#module-Enumerable-label-What-27s+Here), which
|
45
|
+
# * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
|
46
|
+
# * Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which
|
49
47
|
# provides dozens of additional methods.
|
50
48
|
#
|
51
49
|
#
|
50
|
+
# See also Data, which is a somewhat similar, but stricter concept for defining
|
51
|
+
# immutable value objects.
|
52
|
+
#
|
52
53
|
# Here, class Struct provides methods that are useful for:
|
53
54
|
#
|
54
55
|
# * [Creating a Struct
|
55
|
-
# Subclass](
|
56
|
-
# * [Querying](
|
57
|
-
# * [Comparing](
|
58
|
-
# * [Fetching](
|
59
|
-
# * [Assigning](
|
60
|
-
# * [Iterating](
|
61
|
-
# * [Converting](
|
56
|
+
# Subclass](rdoc-ref:Struct@Methods+for+Creating+a+Struct+Subclass)
|
57
|
+
# * [Querying](rdoc-ref:Struct@Methods+for+Querying)
|
58
|
+
# * [Comparing](rdoc-ref:Struct@Methods+for+Comparing)
|
59
|
+
# * [Fetching](rdoc-ref:Struct@Methods+for+Fetching)
|
60
|
+
# * [Assigning](rdoc-ref:Struct@Methods+for+Assigning)
|
61
|
+
# * [Iterating](rdoc-ref:Struct@Methods+for+Iterating)
|
62
|
+
# * [Converting](rdoc-ref:Struct@Methods+for+Converting)
|
62
63
|
#
|
63
64
|
#
|
64
65
|
# ### Methods for Creating a Struct Subclass
|
65
66
|
#
|
66
|
-
# ::new
|
67
|
-
# : Returns a new subclass of Struct.
|
67
|
+
# * ::new: Returns a new subclass of Struct.
|
68
68
|
#
|
69
69
|
#
|
70
70
|
# ### Methods for Querying
|
71
71
|
#
|
72
|
-
# #hash
|
73
|
-
# :
|
74
|
-
# #length, #size
|
75
|
-
# : Returns the number of members.
|
72
|
+
# * #hash: Returns the integer hash code.
|
73
|
+
# * #length, #size: Returns the number of members.
|
76
74
|
#
|
77
75
|
#
|
78
76
|
# ### Methods for Comparing
|
79
77
|
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
# : Returns whether a given object is equal to `self`, using `eql?` to compare
|
85
|
-
# member values.
|
78
|
+
# * #==: Returns whether a given object is equal to `self`, using `==` to
|
79
|
+
# compare member values.
|
80
|
+
# * #eql?: Returns whether a given object is equal to `self`, using `eql?` to
|
81
|
+
# compare member values.
|
86
82
|
#
|
87
83
|
#
|
88
84
|
# ### Methods for Fetching
|
89
85
|
#
|
90
|
-
# #[]
|
91
|
-
# :
|
92
|
-
#
|
93
|
-
# :
|
94
|
-
#
|
95
|
-
# :
|
96
|
-
#
|
97
|
-
# :
|
98
|
-
#
|
99
|
-
#
|
100
|
-
# :
|
101
|
-
# #select, #filter
|
102
|
-
# : Returns an array of member values from `self`, as selected by the given
|
103
|
-
# block.
|
104
|
-
# #values_at
|
105
|
-
# : Returns an array containing values for given member names.
|
86
|
+
# * #[]: Returns the value associated with a given member name.
|
87
|
+
# * #to_a, #values, #deconstruct: Returns the member values in `self` as an
|
88
|
+
# array.
|
89
|
+
# * #deconstruct_keys: Returns a hash of the name/value pairs for given member
|
90
|
+
# names.
|
91
|
+
# * #dig: Returns the object in nested objects that is specified by a given
|
92
|
+
# member name and additional arguments.
|
93
|
+
# * #members: Returns an array of the member names.
|
94
|
+
# * #select, #filter: Returns an array of member values from `self`, as
|
95
|
+
# selected by the given block.
|
96
|
+
# * #values_at: Returns an array containing values for given member names.
|
106
97
|
#
|
107
98
|
#
|
108
99
|
# ### Methods for Assigning
|
109
100
|
#
|
110
|
-
# #[]
|
111
|
-
# : Assigns a given value to a given member name.
|
101
|
+
# * #[]=: Assigns a given value to a given member name.
|
112
102
|
#
|
113
103
|
#
|
114
104
|
# ### Methods for Iterating
|
115
105
|
#
|
116
|
-
# #each
|
117
|
-
# :
|
118
|
-
# #each_pair
|
119
|
-
# : Calls a given block with each member name/value pair.
|
106
|
+
# * #each: Calls a given block with each member name.
|
107
|
+
# * #each_pair: Calls a given block with each member name/value pair.
|
120
108
|
#
|
121
109
|
#
|
122
110
|
# ### Methods for Converting
|
123
111
|
#
|
124
|
-
# #inspect, #to_s
|
125
|
-
# :
|
126
|
-
# #to_h
|
127
|
-
# : Returns a hash of the member name/value pairs in `self`.
|
112
|
+
# * #inspect, #to_s: Returns a string representation of `self`.
|
113
|
+
# * #to_h: Returns a hash of the member name/value pairs in `self`.
|
128
114
|
#
|
129
115
|
class Struct[Elem] < Object
|
130
116
|
include Enumerable[Elem?]
|
@@ -142,8 +128,7 @@ class Struct[Elem] < Object
|
|
142
128
|
#
|
143
129
|
# * May be anonymous, or may have the name given by `class_name`.
|
144
130
|
# * May have members as given by `member_names`.
|
145
|
-
# * May have initialization via ordinary arguments
|
146
|
-
# keyword arguments (if `keyword_init: true` is given).
|
131
|
+
# * May have initialization via ordinary arguments, or via keyword arguments
|
147
132
|
#
|
148
133
|
#
|
149
134
|
# The new subclass has its own method `::new`; thus:
|
@@ -212,6 +197,12 @@ class Struct[Elem] < Object
|
|
212
197
|
# Foo.new(0, 1) # => #<struct Struct::Foo foo=0, bar=1>
|
213
198
|
# Foo.new(0, 1, 2) # Raises ArgumentError: struct size differs
|
214
199
|
#
|
200
|
+
# # Initialization with keyword arguments:
|
201
|
+
# Foo.new(foo: 0) # => #<struct Struct::Foo foo=0, bar=nil>
|
202
|
+
# Foo.new(foo: 0, bar: 1) # => #<struct Struct::Foo foo=0, bar=1>
|
203
|
+
# Foo.new(foo: 0, bar: 1, baz: 2)
|
204
|
+
# # Raises ArgumentError: unknown keywords: baz
|
205
|
+
#
|
215
206
|
# Method `::[]` is an alias for method `::new`.
|
216
207
|
#
|
217
208
|
# * Method `:inspect` returns a string representation of the subclass:
|
@@ -226,18 +217,31 @@ class Struct[Elem] < Object
|
|
226
217
|
#
|
227
218
|
# **Keyword Argument**
|
228
219
|
#
|
229
|
-
# By default, the arguments for initializing an instance of the new subclass
|
230
|
-
#
|
231
|
-
#
|
232
|
-
#
|
233
|
-
#
|
234
|
-
#
|
235
|
-
#
|
236
|
-
#
|
237
|
-
# #
|
238
|
-
#
|
239
|
-
#
|
240
|
-
#
|
220
|
+
# By default, the arguments for initializing an instance of the new subclass can
|
221
|
+
# be both positional and keyword arguments.
|
222
|
+
#
|
223
|
+
# Optional keyword argument `keyword_init:` allows to force only one type of
|
224
|
+
# arguments to be accepted:
|
225
|
+
#
|
226
|
+
# KeywordsOnly = Struct.new(:foo, :bar, keyword_init: true)
|
227
|
+
# KeywordsOnly.new(bar: 1, foo: 0)
|
228
|
+
# # => #<struct KeywordsOnly foo=0, bar=1>
|
229
|
+
# KeywordsOnly.new(0, 1)
|
230
|
+
# # Raises ArgumentError: wrong number of arguments
|
231
|
+
#
|
232
|
+
# PositionalOnly = Struct.new(:foo, :bar, keyword_init: false)
|
233
|
+
# PositionalOnly.new(0, 1)
|
234
|
+
# # => #<struct PositionalOnly foo=0, bar=1>
|
235
|
+
# PositionalOnly.new(bar: 1, foo: 0)
|
236
|
+
# # => #<struct PositionalOnly foo={:foo=>1, :bar=>2}, bar=nil>
|
237
|
+
# # Note that no error is raised, but arguments treated as one hash value
|
238
|
+
#
|
239
|
+
# # Same as not providing keyword_init:
|
240
|
+
# Any = Struct.new(:foo, :bar, keyword_init: nil)
|
241
|
+
# Any.new(foo: 1, bar: 2)
|
242
|
+
# # => #<struct Any foo=1, bar=2>
|
243
|
+
# Any.new(1, 2)
|
244
|
+
# # => #<struct Any foo=1, bar=2>
|
241
245
|
#
|
242
246
|
def initialize: (attribute_name, *attribute_name, ?keyword_init: boolish) ?{ () -> void } -> void
|
243
247
|
|