rbs 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -0
- data/CHANGELOG.md +23 -0
- data/README.md +6 -1
- data/core/array.rbs +2866 -1086
- data/core/basic_object.rbs +150 -30
- data/core/binding.rbs +33 -0
- data/core/builtin.rbs +4 -4
- data/core/class.rbs +43 -5
- data/core/comparable.rbs +57 -0
- data/core/complex.rbs +170 -4
- data/core/constants.rbs +51 -0
- data/core/deprecated.rbs +7 -0
- data/core/dir.rbs +305 -20
- data/core/encoding.rbs +472 -77
- data/core/enumerable.rbs +2173 -234
- data/core/enumerator.rbs +448 -182
- data/core/env.rbs +448 -1
- data/core/errno.rbs +1 -10
- data/core/errors.rbs +152 -2
- data/core/exception.rbs +201 -127
- data/core/false_class.rbs +27 -0
- data/core/fiber.rbs +118 -37
- data/core/fiber_error.rbs +8 -9
- data/core/file.rbs +1059 -139
- data/core/file_test.rbs +287 -32
- data/core/float.rbs +776 -300
- data/core/gc.rbs +185 -34
- data/core/global_variables.rbs +5 -1
- data/core/hash.rbs +1582 -649
- data/core/integer.rbs +974 -204
- data/core/io/buffer.rbs +710 -0
- data/core/io/wait.rbs +29 -8
- data/core/io.rbs +2438 -417
- data/core/kernel.rbs +2315 -316
- data/core/marshal.rbs +37 -2
- data/core/match_data.rbs +123 -6
- data/core/math.rbs +126 -6
- data/core/method.rbs +226 -102
- data/core/module.rbs +421 -45
- data/core/nil_class.rbs +64 -0
- data/core/numeric.rbs +620 -142
- data/core/object.rbs +453 -81
- data/core/object_space.rbs +92 -2
- data/core/proc.rbs +482 -285
- data/core/process.rbs +443 -34
- data/core/ractor.rbs +232 -9
- data/core/random.rbs +151 -52
- data/core/range.rbs +885 -160
- data/core/rational.rbs +122 -6
- data/core/rb_config.rbs +14 -4
- data/core/refinement.rbs +44 -0
- data/core/regexp.rbs +156 -14
- data/core/ruby_vm.rbs +42 -3
- data/core/signal.rbs +78 -39
- data/core/string.rbs +2123 -567
- data/core/string_io.rbs +204 -0
- data/core/struct.rbs +283 -28
- data/core/symbol.rbs +304 -30
- data/core/thread.rbs +1288 -688
- data/core/thread_group.rbs +66 -10
- data/core/time.rbs +643 -217
- data/core/trace_point.rbs +100 -12
- data/core/true_class.rbs +24 -0
- data/core/unbound_method.rbs +73 -7
- data/core/warning.rbs +37 -12
- data/docs/CONTRIBUTING.md +40 -34
- data/docs/stdlib.md +3 -102
- data/lib/rbs/annotate/annotations.rb +197 -0
- data/lib/rbs/annotate/formatter.rb +80 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
- data/lib/rbs/annotate/rdoc_source.rb +120 -0
- data/lib/rbs/annotate.rb +6 -0
- data/lib/rbs/cli.rb +45 -1
- data/lib/rbs/definition_builder.rb +5 -1
- data/lib/rbs/location_aux.rb +12 -0
- data/lib/rbs/prototype/rb.rb +12 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/{collections.rbs → sources.rbs} +0 -0
- data/sig/location.rbs +6 -0
- data/sig/method_types.rbs +5 -1
- data/sig/polyfill.rbs +78 -0
- data/stdlib/abbrev/0/abbrev.rbs +6 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +31 -0
- data/stdlib/benchmark/0/benchmark.rbs +74 -3
- data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
- data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
- data/stdlib/cgi/0/core.rbs +59 -0
- data/stdlib/coverage/0/coverage.rbs +164 -2
- data/stdlib/csv/0/csv.rbs +2862 -398
- data/stdlib/date/0/date.rbs +483 -25
- data/stdlib/date/0/date_time.rbs +187 -12
- data/stdlib/dbm/0/dbm.rbs +152 -17
- data/stdlib/digest/0/digest.rbs +146 -0
- data/stdlib/erb/0/erb.rbs +65 -245
- data/stdlib/fiber/0/fiber.rbs +73 -91
- data/stdlib/fileutils/0/fileutils.rbs +301 -1
- data/stdlib/find/0/find.rbs +9 -0
- data/stdlib/forwardable/0/forwardable.rbs +65 -1
- data/stdlib/io-console/0/io-console.rbs +227 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
- data/stdlib/json/0/json.rbs +1146 -144
- data/stdlib/logger/0/formatter.rbs +24 -0
- data/stdlib/logger/0/log_device.rbs +64 -0
- data/stdlib/logger/0/logger.rbs +165 -13
- data/stdlib/logger/0/period.rbs +10 -0
- data/stdlib/logger/0/severity.rbs +26 -0
- data/stdlib/monitor/0/monitor.rbs +163 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
- data/stdlib/net-http/0/net-http.rbs +1492 -683
- data/stdlib/nkf/0/nkf.rbs +372 -0
- data/stdlib/objspace/0/objspace.rbs +149 -90
- data/stdlib/openssl/0/openssl.rbs +8108 -71
- data/stdlib/optparse/0/optparse.rbs +487 -19
- data/stdlib/pathname/0/pathname.rbs +425 -124
- data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
- data/stdlib/prime/0/integer-extension.rbs +20 -2
- data/stdlib/prime/0/prime.rbs +88 -21
- data/stdlib/pstore/0/pstore.rbs +102 -0
- data/stdlib/pty/0/pty.rbs +64 -14
- data/stdlib/resolv/0/resolv.rbs +420 -31
- data/stdlib/rubygems/0/basic_specification.rbs +4 -1
- data/stdlib/rubygems/0/config_file.rbs +33 -1
- data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
- data/stdlib/rubygems/0/installer.rbs +13 -1
- data/stdlib/rubygems/0/path_support.rbs +4 -1
- data/stdlib/rubygems/0/platform.rbs +5 -1
- data/stdlib/rubygems/0/request_set.rbs +44 -2
- data/stdlib/rubygems/0/requirement.rbs +65 -2
- data/stdlib/rubygems/0/rubygems.rbs +407 -0
- data/stdlib/rubygems/0/source_list.rbs +13 -0
- data/stdlib/rubygems/0/specification.rbs +21 -1
- data/stdlib/rubygems/0/stream_ui.rbs +3 -1
- data/stdlib/rubygems/0/uninstaller.rbs +8 -1
- data/stdlib/rubygems/0/version.rbs +60 -157
- data/stdlib/securerandom/0/securerandom.rbs +44 -0
- data/stdlib/set/0/set.rbs +420 -106
- data/stdlib/shellwords/0/shellwords.rbs +55 -77
- data/stdlib/singleton/0/singleton.rbs +20 -0
- data/stdlib/socket/0/addrinfo.rbs +210 -9
- data/stdlib/socket/0/basic_socket.rbs +103 -11
- data/stdlib/socket/0/ip_socket.rbs +31 -9
- data/stdlib/socket/0/socket.rbs +586 -38
- data/stdlib/socket/0/tcp_server.rbs +22 -2
- data/stdlib/socket/0/tcp_socket.rbs +12 -1
- data/stdlib/socket/0/udp_socket.rbs +25 -2
- data/stdlib/socket/0/unix_server.rbs +22 -2
- data/stdlib/socket/0/unix_socket.rbs +45 -5
- data/stdlib/strscan/0/string_scanner.rbs +210 -9
- data/stdlib/tempfile/0/tempfile.rbs +58 -10
- data/stdlib/time/0/time.rbs +208 -116
- data/stdlib/timeout/0/timeout.rbs +10 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
- data/stdlib/tsort/0/cyclic.rbs +1 -0
- data/stdlib/tsort/0/interfaces.rbs +1 -0
- data/stdlib/tsort/0/tsort.rbs +42 -0
- data/stdlib/uri/0/common.rbs +57 -8
- data/stdlib/uri/0/file.rbs +55 -109
- data/stdlib/uri/0/ftp.rbs +6 -3
- data/stdlib/uri/0/generic.rbs +556 -327
- data/stdlib/uri/0/http.rbs +26 -115
- data/stdlib/uri/0/https.rbs +8 -102
- data/stdlib/uri/0/ldap.rbs +143 -137
- data/stdlib/uri/0/ldaps.rbs +8 -102
- data/stdlib/uri/0/mailto.rbs +3 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
- data/stdlib/uri/0/ws.rbs +6 -3
- data/stdlib/uri/0/wss.rbs +5 -3
- data/stdlib/yaml/0/dbm.rbs +151 -87
- data/stdlib/yaml/0/store.rbs +6 -0
- data/stdlib/zlib/0/zlib.rbs +90 -31
- metadata +17 -5
- data/lib/rbs/location.rb +0 -221
data/core/struct.rbs
CHANGED
@@ -1,40 +1,295 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# .
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
1
|
+
# <!-- rdoc-file=struct.c -->
|
2
|
+
# Class Struct provides a convenient way to create a simple class that can store
|
3
|
+
# and fetch values.
|
4
|
+
#
|
5
|
+
# This example creates a subclass of `Struct`, `Struct::Customer`; the first
|
6
|
+
# argument, a string, is the name of the subclass; the other arguments, symbols,
|
7
|
+
# determine the *members* of the new subclass.
|
8
|
+
#
|
9
|
+
# Customer = Struct.new('Customer', :name, :address, :zip)
|
10
|
+
# Customer.name # => "Struct::Customer"
|
11
|
+
# Customer.class # => Class
|
12
|
+
# Customer.superclass # => Struct
|
13
|
+
#
|
14
|
+
# Corresponding to each member are two methods, a writer and a reader, that
|
15
|
+
# store and fetch values:
|
16
|
+
#
|
17
|
+
# methods = Customer.instance_methods false
|
18
|
+
# methods # => [:zip, :address=, :zip=, :address, :name, :name=]
|
19
|
+
#
|
20
|
+
# An instance of the subclass may be created, and its members assigned values,
|
21
|
+
# via method `::new`:
|
22
|
+
#
|
23
|
+
# joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
24
|
+
# joe # => #<struct Struct::Customer name="Joe Smith", address="123 Maple, Anytown NC", zip=12345>
|
25
|
+
#
|
26
|
+
# The member values may be managed thus:
|
27
|
+
#
|
28
|
+
# joe.name # => "Joe Smith"
|
29
|
+
# joe.name = 'Joseph Smith'
|
30
|
+
# joe.name # => "Joseph Smith"
|
31
|
+
#
|
32
|
+
# And thus; note that member name may be expressed as either a string or a
|
33
|
+
# symbol:
|
34
|
+
#
|
35
|
+
# joe[:name] # => "Joseph Smith"
|
36
|
+
# joe[:name] = 'Joseph Smith, Jr.'
|
37
|
+
# joe['name'] # => "Joseph Smith, Jr."
|
38
|
+
#
|
39
|
+
# See Struct::new.
|
40
|
+
#
|
41
|
+
# ## What's Here
|
42
|
+
#
|
43
|
+
# First, what's elsewhere. Class Struct:
|
44
|
+
#
|
45
|
+
# * Inherits from [class
|
46
|
+
# Object](Object.html#class-Object-label-What-27s+Here).
|
47
|
+
# * Includes [module
|
48
|
+
# Enumerable](Enumerable.html#module-Enumerable-label-What-27s+Here), which
|
49
|
+
# provides dozens of additional methods.
|
50
|
+
#
|
51
|
+
#
|
52
|
+
# Here, class Struct provides methods that are useful for:
|
53
|
+
#
|
54
|
+
# * [Creating a Struct
|
55
|
+
# Subclass](#class-Struct-label-Methods+for+Creating+a+Struct+Subclass)
|
56
|
+
# * [Querying](#class-Struct-label-Methods+for+Querying)
|
57
|
+
# * [Comparing](#class-Struct-label-Methods+for+Comparing)
|
58
|
+
# * [Fetching](#class-Struct-label-Methods+for+Fetching)
|
59
|
+
# * [Assigning](#class-Struct-label-Methods+for+Assigning)
|
60
|
+
# * [Iterating](#class-Struct-label-Methods+for+Iterating)
|
61
|
+
# * [Converting](#class-Struct-label-Methods+for+Converting)
|
62
|
+
#
|
63
|
+
#
|
64
|
+
# ### Methods for Creating a Struct Subclass
|
65
|
+
#
|
66
|
+
# ::new
|
67
|
+
# : Returns a new subclass of Struct.
|
68
|
+
#
|
69
|
+
#
|
70
|
+
# ### Methods for Querying
|
71
|
+
#
|
72
|
+
# #hash
|
73
|
+
# : Returns the integer hash code.
|
74
|
+
# #length, #size
|
75
|
+
# : Returns the number of members.
|
76
|
+
#
|
77
|
+
#
|
78
|
+
# ### Methods for Comparing
|
79
|
+
#
|
80
|
+
# [#==](#method-i-3D-3D)
|
81
|
+
# : Returns whether a given object is equal to `self`, using `==` to compare
|
82
|
+
# member values.
|
83
|
+
# #eql?
|
84
|
+
# : Returns whether a given object is equal to `self`, using `eql?` to compare
|
85
|
+
# member values.
|
86
|
+
#
|
87
|
+
#
|
88
|
+
# ### Methods for Fetching
|
89
|
+
#
|
90
|
+
# #[]
|
91
|
+
# : Returns the value associated with a given member name.
|
92
|
+
# #to_a, #values, #deconstruct
|
93
|
+
# : Returns the member values in `self` as an array.
|
94
|
+
# #deconstruct_keys
|
95
|
+
# : Returns a hash of the name/value pairs for given member names.
|
96
|
+
# #dig
|
97
|
+
# : Returns the object in nested objects that is specified by a given member
|
98
|
+
# name and additional arguments.
|
99
|
+
# #members
|
100
|
+
# : Returns an array of the member names.
|
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.
|
106
|
+
#
|
107
|
+
#
|
108
|
+
# ### Methods for Assigning
|
109
|
+
#
|
110
|
+
# #[]=
|
111
|
+
# : Assigns a given value to a given member name.
|
112
|
+
#
|
113
|
+
#
|
114
|
+
# ### Methods for Iterating
|
115
|
+
#
|
116
|
+
# #each
|
117
|
+
# : Calls a given block with each member name.
|
118
|
+
# #each_pair
|
119
|
+
# : Calls a given block with each member name/value pair.
|
120
|
+
#
|
121
|
+
#
|
122
|
+
# ### Methods for Converting
|
123
|
+
#
|
124
|
+
# #inspect, #to_s
|
125
|
+
# : Returns a string representation of `self`.
|
126
|
+
# #to_h
|
127
|
+
# : Returns a hash of the member name/value pairs in `self`.
|
128
|
+
#
|
29
129
|
class Struct[Elem] < Object
|
30
130
|
include Enumerable[Elem?]
|
31
131
|
|
32
132
|
type attribute_name = Symbol | String
|
33
133
|
|
134
|
+
# <!--
|
135
|
+
# rdoc-file=struct.c
|
136
|
+
# - Struct.new(*member_names, keyword_init: false){|Struct_subclass| ... } -> Struct_subclass
|
137
|
+
# - Struct.new(class_name, *member_names, keyword_init: false){|Struct_subclass| ... } -> Struct_subclass
|
138
|
+
# - Struct_subclass.new(*member_names) -> Struct_subclass_instance
|
139
|
+
# - Struct_subclass.new(**member_names) -> Struct_subclass_instance
|
140
|
+
# -->
|
141
|
+
# `Struct.new` returns a new subclass of `Struct`. The new subclass:
|
142
|
+
#
|
143
|
+
# * May be anonymous, or may have the name given by `class_name`.
|
144
|
+
# * May have members as given by `member_names`.
|
145
|
+
# * May have initialization via ordinary arguments (the default) or via
|
146
|
+
# keyword arguments (if `keyword_init: true` is given).
|
147
|
+
#
|
148
|
+
#
|
149
|
+
# The new subclass has its own method `::new`; thus:
|
150
|
+
#
|
151
|
+
# Foo = Struct.new('Foo', :foo, :bar) # => Struct::Foo
|
152
|
+
# f = Foo.new(0, 1) # => #<struct Struct::Foo foo=0, bar=1>
|
153
|
+
#
|
154
|
+
# **\Class Name**
|
155
|
+
#
|
156
|
+
# With string argument `class_name`, returns a new subclass of `Struct` named
|
157
|
+
# `Struct::*class_name`*:
|
158
|
+
#
|
159
|
+
# Foo = Struct.new('Foo', :foo, :bar) # => Struct::Foo
|
160
|
+
# Foo.name # => "Struct::Foo"
|
161
|
+
# Foo.superclass # => Struct
|
162
|
+
#
|
163
|
+
# Without string argument `class_name`, returns a new anonymous subclass of
|
164
|
+
# `Struct`:
|
165
|
+
#
|
166
|
+
# Struct.new(:foo, :bar).name # => nil
|
167
|
+
#
|
168
|
+
# **Block**
|
169
|
+
#
|
170
|
+
# With a block given, the created subclass is yielded to the block:
|
171
|
+
#
|
172
|
+
# Customer = Struct.new('Customer', :name, :address) do |new_class|
|
173
|
+
# p "The new subclass is #{new_class}"
|
174
|
+
# def greeting
|
175
|
+
# "Hello #{name} at #{address}"
|
176
|
+
# end
|
177
|
+
# end # => Struct::Customer
|
178
|
+
# dave = Customer.new('Dave', '123 Main')
|
179
|
+
# dave # => #<struct Struct::Customer name="Dave", address="123 Main">
|
180
|
+
# dave.greeting # => "Hello Dave at 123 Main"
|
181
|
+
#
|
182
|
+
# Output, from `Struct.new`:
|
183
|
+
#
|
184
|
+
# "The new subclass is Struct::Customer"
|
185
|
+
#
|
186
|
+
# **Member Names**
|
187
|
+
#
|
188
|
+
# Symbol arguments `member_names` determines the members of the new subclass:
|
189
|
+
#
|
190
|
+
# Struct.new(:foo, :bar).members # => [:foo, :bar]
|
191
|
+
# Struct.new('Foo', :foo, :bar).members # => [:foo, :bar]
|
192
|
+
#
|
193
|
+
# The new subclass has instance methods corresponding to `member_names`:
|
194
|
+
#
|
195
|
+
# Foo = Struct.new('Foo', :foo, :bar)
|
196
|
+
# Foo.instance_methods(false) # => [:foo, :bar, :foo=, :bar=]
|
197
|
+
# f = Foo.new # => #<struct Struct::Foo foo=nil, bar=nil>
|
198
|
+
# f.foo # => nil
|
199
|
+
# f.foo = 0 # => 0
|
200
|
+
# f.bar # => nil
|
201
|
+
# f.bar = 1 # => 1
|
202
|
+
# f # => #<struct Struct::Foo foo=0, bar=1>
|
203
|
+
#
|
204
|
+
# **Singleton Methods**
|
205
|
+
#
|
206
|
+
# A subclass returned by Struct.new has these singleton methods:
|
207
|
+
#
|
208
|
+
# * Method `::new ` creates an instance of the subclass:
|
209
|
+
#
|
210
|
+
# Foo.new # => #<struct Struct::Foo foo=nil, bar=nil>
|
211
|
+
# Foo.new(0) # => #<struct Struct::Foo foo=0, bar=nil>
|
212
|
+
# Foo.new(0, 1) # => #<struct Struct::Foo foo=0, bar=1>
|
213
|
+
# Foo.new(0, 1, 2) # Raises ArgumentError: struct size differs
|
214
|
+
#
|
215
|
+
# Method `::[]` is an alias for method `::new`.
|
216
|
+
#
|
217
|
+
# * Method `:inspect` returns a string representation of the subclass:
|
218
|
+
#
|
219
|
+
# Foo.inspect
|
220
|
+
# # => "Struct::Foo"
|
221
|
+
#
|
222
|
+
# * Method `::members` returns an array of the member names:
|
223
|
+
#
|
224
|
+
# Foo.members # => [:foo, :bar]
|
225
|
+
#
|
226
|
+
#
|
227
|
+
# **Keyword Argument**
|
228
|
+
#
|
229
|
+
# By default, the arguments for initializing an instance of the new subclass are
|
230
|
+
# ordinary arguments (not keyword arguments). With optional keyword argument
|
231
|
+
# `keyword_init: true`, the new subclass is initialized with keyword arguments:
|
232
|
+
#
|
233
|
+
# # Without keyword_init: true.
|
234
|
+
# Foo = Struct.new('Foo', :foo, :bar)
|
235
|
+
# Foo # => Struct::Foo
|
236
|
+
# Foo.new(0, 1) # => #<struct Struct::Foo foo=0, bar=1>
|
237
|
+
# # With keyword_init: true.
|
238
|
+
# Bar = Struct.new(:foo, :bar, keyword_init: true)
|
239
|
+
# Bar # => # => Bar(keyword_init: true)
|
240
|
+
# Bar.new(bar: 1, foo: 0) # => #<struct Bar foo=0, bar=1>
|
241
|
+
#
|
34
242
|
def initialize: (attribute_name, *attribute_name, ?keyword_init: boolish) ?{ () -> void } -> void
|
35
243
|
|
244
|
+
# <!--
|
245
|
+
# rdoc-file=struct.c
|
246
|
+
# - each {|value| ... } -> self
|
247
|
+
# - each -> enumerator
|
248
|
+
# -->
|
249
|
+
# Calls the given block with the value of each member; returns `self`:
|
250
|
+
#
|
251
|
+
# Customer = Struct.new(:name, :address, :zip)
|
252
|
+
# joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
|
253
|
+
# joe.each {|value| p value }
|
254
|
+
#
|
255
|
+
# Output:
|
256
|
+
#
|
257
|
+
# "Joe Smith"
|
258
|
+
# "123 Maple, Anytown NC"
|
259
|
+
# 12345
|
260
|
+
#
|
261
|
+
# Returns an Enumerator if no block is given.
|
262
|
+
#
|
263
|
+
# Related: #each_pair.
|
264
|
+
#
|
36
265
|
def each: () -> ::Enumerator[Elem?, self]
|
37
266
|
| () { (Elem? item) -> void } -> self
|
38
267
|
|
268
|
+
# <!--
|
269
|
+
# rdoc-file=struct.c
|
270
|
+
# - StructClass::members -> array_of_symbols
|
271
|
+
# -->
|
272
|
+
# Returns the member names of the Struct descendant as an array:
|
273
|
+
#
|
274
|
+
# Customer = Struct.new(:name, :address, :zip)
|
275
|
+
# Customer.members # => [:name, :address, :zip]
|
276
|
+
#
|
39
277
|
def self.members: () -> ::Array[Symbol]
|
278
|
+
|
279
|
+
# <!--
|
280
|
+
# rdoc-file=struct.c
|
281
|
+
# - StructClass::keyword_init? -> true or falsy value
|
282
|
+
# -->
|
283
|
+
# Returns `true` if the class was initialized with `keyword_init: true`.
|
284
|
+
# Otherwise returns `nil` or `false`.
|
285
|
+
#
|
286
|
+
# Examples:
|
287
|
+
# Foo = Struct.new(:a)
|
288
|
+
# Foo.keyword_init? # => nil
|
289
|
+
# Bar = Struct.new(:a, keyword_init: true)
|
290
|
+
# Bar.keyword_init? # => true
|
291
|
+
# Baz = Struct.new(:a, keyword_init: false)
|
292
|
+
# Baz.keyword_init? # => false
|
293
|
+
#
|
294
|
+
def self.keyword_init?: () -> (true | false | nil)
|
40
295
|
end
|