rbs 2.0.0 → 2.2.2
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 +34 -0
- data/.github/workflows/ruby.yml +5 -0
- data/CHANGELOG.md +82 -0
- data/README.md +6 -1
- data/Rakefile +56 -21
- 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 +1214 -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 +1060 -142
- 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 +2319 -318
- 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/docs/syntax.md +54 -11
- data/ext/rbs_extension/extconf.rb +1 -0
- data/ext/rbs_extension/lexer.h +5 -0
- data/ext/rbs_extension/lexstate.c +6 -0
- data/ext/rbs_extension/parser.c +85 -10
- data/ext/rbs_extension/ruby_objs.c +4 -2
- data/ext/rbs_extension/ruby_objs.h +2 -2
- data/goodcheck.yml +0 -11
- 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/ast/members.rb +21 -13
- data/lib/rbs/buffer.rb +17 -11
- data/lib/rbs/cli.rb +48 -1
- data/lib/rbs/definition_builder/method_builder.rb +28 -16
- data/lib/rbs/definition_builder.rb +6 -2
- data/lib/rbs/environment.rb +8 -4
- data/lib/rbs/location_aux.rb +12 -0
- data/lib/rbs/namespace.rb +1 -1
- data/lib/rbs/prototype/rb.rb +12 -0
- data/lib/rbs/type_alias_regularity.rb +6 -4
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +1 -1
- data/lib/rbs/validator.rb +6 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +54 -4
- data/lib/rbs.rb +0 -2
- data/schema/typeParam.json +3 -3
- 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/buffer.rbs +6 -2
- data/sig/cli.rbs +2 -0
- data/sig/collection/{collections.rbs → sources.rbs} +0 -0
- data/sig/location.rbs +6 -0
- data/sig/members.rbs +24 -18
- data/sig/method_builder.rbs +5 -4
- data/sig/method_types.rbs +5 -1
- data/sig/polyfill.rbs +78 -0
- data/sig/validator.rbs +3 -1
- data/sig/writer.rbs +79 -2
- 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 +649 -21
- 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 +1147 -145
- 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/manifest.yaml +1 -0
- data/stdlib/net-http/0/net-http.rbs +1513 -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 +423 -109
- 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 +558 -329
- data/stdlib/uri/0/http.rbs +60 -114
- 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 +18 -6
- data/lib/rbs/location.rb +0 -221
- data/sig/char_scanner.rbs +0 -9
data/core/module.rbs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# <!-- rdoc-file=object.c -->
|
|
1
2
|
# A Module is a collection of methods and constants. The methods in a module may
|
|
2
3
|
# be instance methods or module methods. Instance methods appear as methods in a
|
|
3
4
|
# class when the module is included, module methods do not. Conversely, module
|
|
@@ -19,6 +20,11 @@
|
|
|
19
20
|
# Mod.instance_methods #=> [:meth]
|
|
20
21
|
#
|
|
21
22
|
class Module < Object
|
|
23
|
+
# <!--
|
|
24
|
+
# rdoc-file=eval.c
|
|
25
|
+
# - Module.constants -> array
|
|
26
|
+
# - Module.constants(inherited) -> array
|
|
27
|
+
# -->
|
|
22
28
|
# In the first form, returns an array of the names of all constants accessible
|
|
23
29
|
# from the point of call. This list includes the names of all modules and
|
|
24
30
|
# classes defined in the global scope.
|
|
@@ -36,6 +42,10 @@ class Module < Object
|
|
|
36
42
|
#
|
|
37
43
|
def self.constants: () -> ::Array[Integer]
|
|
38
44
|
|
|
45
|
+
# <!--
|
|
46
|
+
# rdoc-file=eval.c
|
|
47
|
+
# - Module.nesting -> array
|
|
48
|
+
# -->
|
|
39
49
|
# Returns the list of `Modules` nested at the point of call.
|
|
40
50
|
#
|
|
41
51
|
# module M1
|
|
@@ -48,6 +58,10 @@ class Module < Object
|
|
|
48
58
|
#
|
|
49
59
|
def self.nesting: () -> ::Array[Module]
|
|
50
60
|
|
|
61
|
+
# <!--
|
|
62
|
+
# rdoc-file=eval.c
|
|
63
|
+
# - used_modules -> array
|
|
64
|
+
# -->
|
|
51
65
|
# Returns an array of all modules used in the current scope. The ordering of
|
|
52
66
|
# modules in the resulting array is not defined.
|
|
53
67
|
#
|
|
@@ -71,18 +85,30 @@ class Module < Object
|
|
|
71
85
|
#
|
|
72
86
|
def self.used_modules: () -> ::Array[Module]
|
|
73
87
|
|
|
88
|
+
# <!--
|
|
89
|
+
# rdoc-file=object.c
|
|
90
|
+
# - mod < other -> true, false, or nil
|
|
91
|
+
# -->
|
|
74
92
|
# Returns true if *mod* is a subclass of *other*. Returns `nil` if there's no
|
|
75
93
|
# relationship between the two. (Think of the relationship in terms of the class
|
|
76
94
|
# definition: "class A < B" implies "A < B".)
|
|
77
95
|
#
|
|
78
96
|
def <: (Module other) -> bool?
|
|
79
97
|
|
|
98
|
+
# <!--
|
|
99
|
+
# rdoc-file=object.c
|
|
100
|
+
# - mod <= other -> true, false, or nil
|
|
101
|
+
# -->
|
|
80
102
|
# Returns true if *mod* is a subclass of *other* or is the same as *other*.
|
|
81
103
|
# Returns `nil` if there's no relationship between the two. (Think of the
|
|
82
104
|
# relationship in terms of the class definition: "class A < B" implies "A < B".)
|
|
83
105
|
#
|
|
84
106
|
def <=: (Module other) -> bool?
|
|
85
107
|
|
|
108
|
+
# <!--
|
|
109
|
+
# rdoc-file=object.c
|
|
110
|
+
# - module <=> other_module -> -1, 0, +1, or nil
|
|
111
|
+
# -->
|
|
86
112
|
# Comparison---Returns -1, 0, +1 or nil depending on whether `module` includes
|
|
87
113
|
# `other_module`, they are the same, or if `module` is included by
|
|
88
114
|
# `other_module`.
|
|
@@ -92,6 +118,12 @@ class Module < Object
|
|
|
92
118
|
#
|
|
93
119
|
def <=>: (untyped other) -> Integer?
|
|
94
120
|
|
|
121
|
+
# <!--
|
|
122
|
+
# rdoc-file=object.c
|
|
123
|
+
# - obj == other -> true or false
|
|
124
|
+
# - obj.equal?(other) -> true or false
|
|
125
|
+
# - obj.eql?(other) -> true or false
|
|
126
|
+
# -->
|
|
95
127
|
# Equality --- At the Object level, #== returns `true` only if `obj` and `other`
|
|
96
128
|
# are the same object. Typically, this method is overridden in descendant
|
|
97
129
|
# classes to provide class-specific meaning.
|
|
@@ -123,29 +155,45 @@ class Module < Object
|
|
|
123
155
|
#
|
|
124
156
|
def ==: (untyped other) -> bool
|
|
125
157
|
|
|
158
|
+
# <!--
|
|
159
|
+
# rdoc-file=object.c
|
|
160
|
+
# - mod === obj -> true or false
|
|
161
|
+
# -->
|
|
126
162
|
# Case Equality---Returns `true` if *obj* is an instance of *mod* or an instance
|
|
127
163
|
# of one of *mod*'s descendants. Of limited use for modules, but can be used in
|
|
128
164
|
# `case` statements to classify objects by class.
|
|
129
165
|
#
|
|
130
166
|
def ===: (untyped other) -> bool
|
|
131
167
|
|
|
168
|
+
# <!--
|
|
169
|
+
# rdoc-file=object.c
|
|
170
|
+
# - mod > other -> true, false, or nil
|
|
171
|
+
# -->
|
|
132
172
|
# Returns true if *mod* is an ancestor of *other*. Returns `nil` if there's no
|
|
133
173
|
# relationship between the two. (Think of the relationship in terms of the class
|
|
134
174
|
# definition: "class A < B" implies "B > A".)
|
|
135
175
|
#
|
|
136
176
|
def >: (Module other) -> bool?
|
|
137
177
|
|
|
178
|
+
# <!--
|
|
179
|
+
# rdoc-file=object.c
|
|
180
|
+
# - mod >= other -> true, false, or nil
|
|
181
|
+
# -->
|
|
138
182
|
# Returns true if *mod* is an ancestor of *other*, or the two modules are the
|
|
139
183
|
# same. Returns `nil` if there's no relationship between the two. (Think of the
|
|
140
184
|
# relationship in terms of the class definition: "class A < B" implies "B > A".)
|
|
141
185
|
#
|
|
142
186
|
def >=: (Module other) -> bool?
|
|
143
187
|
|
|
188
|
+
# <!--
|
|
189
|
+
# rdoc-file=vm_method.c
|
|
190
|
+
# - alias_method(new_name, old_name) -> symbol
|
|
191
|
+
# -->
|
|
144
192
|
# Makes *new_name* a new copy of the method *old_name*. This can be used to
|
|
145
193
|
# retain access to methods that are overridden.
|
|
146
194
|
#
|
|
147
195
|
# module Mod
|
|
148
|
-
# alias_method :orig_exit, :exit
|
|
196
|
+
# alias_method :orig_exit, :exit #=> :orig_exit
|
|
149
197
|
# def exit(code=0)
|
|
150
198
|
# puts "Exiting with code #{code}"
|
|
151
199
|
# orig_exit(code)
|
|
@@ -160,6 +208,10 @@ class Module < Object
|
|
|
160
208
|
#
|
|
161
209
|
def alias_method: (::Symbol | ::String new_name, ::Symbol | ::String old_name) -> ::Symbol
|
|
162
210
|
|
|
211
|
+
# <!--
|
|
212
|
+
# rdoc-file=object.c
|
|
213
|
+
# - mod.ancestors -> array
|
|
214
|
+
# -->
|
|
163
215
|
# Returns a list of modules included/prepended in *mod* (including *mod*
|
|
164
216
|
# itself).
|
|
165
217
|
#
|
|
@@ -175,6 +227,10 @@ class Module < Object
|
|
|
175
227
|
#
|
|
176
228
|
def ancestors: () -> ::Array[Module]
|
|
177
229
|
|
|
230
|
+
# <!--
|
|
231
|
+
# rdoc-file=eval.c
|
|
232
|
+
# - append_features(mod) -> mod
|
|
233
|
+
# -->
|
|
178
234
|
# When this module is included in another, Ruby calls #append_features in this
|
|
179
235
|
# module, passing it the receiving module in *mod*. Ruby's default
|
|
180
236
|
# implementation is to add the constants, methods, and module variables of this
|
|
@@ -183,29 +239,53 @@ class Module < Object
|
|
|
183
239
|
#
|
|
184
240
|
def append_features: (Module arg0) -> self
|
|
185
241
|
|
|
242
|
+
# <!--
|
|
243
|
+
# rdoc-file=object.c
|
|
244
|
+
# - attr_accessor(symbol, ...) -> array
|
|
245
|
+
# - attr_accessor(string, ...) -> array
|
|
246
|
+
# -->
|
|
186
247
|
# Defines a named attribute for this module, where the name is
|
|
187
248
|
# *symbol.*`id2name`, creating an instance variable (`@name`) and a
|
|
188
249
|
# corresponding access method to read it. Also creates a method called `name=`
|
|
189
|
-
# to set the attribute. String arguments are converted to symbols.
|
|
250
|
+
# to set the attribute. String arguments are converted to symbols. Returns an
|
|
251
|
+
# array of defined method names as symbols.
|
|
190
252
|
#
|
|
191
253
|
# module Mod
|
|
192
|
-
# attr_accessor(:one, :two)
|
|
254
|
+
# attr_accessor(:one, :two) #=> [:one, :one=, :two, :two=]
|
|
193
255
|
# end
|
|
194
256
|
# Mod.instance_methods.sort #=> [:one, :one=, :two, :two=]
|
|
195
257
|
#
|
|
196
|
-
def
|
|
258
|
+
def attr_accessor: (*Symbol | String arg0) -> NilClass
|
|
197
259
|
|
|
260
|
+
# <!--
|
|
261
|
+
# rdoc-file=object.c
|
|
262
|
+
# - attr_reader(symbol, ...) -> array
|
|
263
|
+
# - attr(symbol, ...) -> array
|
|
264
|
+
# - attr_reader(string, ...) -> array
|
|
265
|
+
# - attr(string, ...) -> array
|
|
266
|
+
# -->
|
|
198
267
|
# Creates instance variables and corresponding methods that return the value of
|
|
199
268
|
# each instance variable. Equivalent to calling ```attr`*:name*'' on each name
|
|
200
|
-
# in turn. String arguments are converted to symbols.
|
|
269
|
+
# in turn. String arguments are converted to symbols. Returns an array of
|
|
270
|
+
# defined method names as symbols.
|
|
201
271
|
#
|
|
202
|
-
def
|
|
272
|
+
def attr_reader: (*Symbol | String arg0) -> NilClass
|
|
203
273
|
|
|
274
|
+
# <!--
|
|
275
|
+
# rdoc-file=object.c
|
|
276
|
+
# - attr_writer(symbol, ...) -> array
|
|
277
|
+
# - attr_writer(string, ...) -> array
|
|
278
|
+
# -->
|
|
204
279
|
# Creates an accessor method to allow assignment to the attribute
|
|
205
|
-
# *symbol*`.id2name`. String arguments are converted to symbols.
|
|
280
|
+
# *symbol*`.id2name`. String arguments are converted to symbols. Returns an
|
|
281
|
+
# array of defined method names as symbols.
|
|
206
282
|
#
|
|
207
|
-
def
|
|
283
|
+
def attr_writer: (*Symbol | String arg0) -> NilClass
|
|
208
284
|
|
|
285
|
+
# <!--
|
|
286
|
+
# rdoc-file=load.c
|
|
287
|
+
# - mod.autoload(module, filename) -> nil
|
|
288
|
+
# -->
|
|
209
289
|
# Registers *filename* to be loaded (using Kernel::require) the first time that
|
|
210
290
|
# *module* (which may be a String or a symbol) is accessed in the namespace of
|
|
211
291
|
# *mod*.
|
|
@@ -217,6 +297,10 @@ class Module < Object
|
|
|
217
297
|
#
|
|
218
298
|
def autoload: (Symbol _module, String filename) -> NilClass
|
|
219
299
|
|
|
300
|
+
# <!--
|
|
301
|
+
# rdoc-file=load.c
|
|
302
|
+
# - mod.autoload?(name, inherit=true) -> String or nil
|
|
303
|
+
# -->
|
|
220
304
|
# Returns *filename* to be loaded if *name* is registered as `autoload` in the
|
|
221
305
|
# namespace of *mod* or one of its ancestors.
|
|
222
306
|
#
|
|
@@ -239,6 +323,7 @@ class Module < Object
|
|
|
239
323
|
#
|
|
240
324
|
def autoload?: (Symbol name, ?boolish inherit) -> String?
|
|
241
325
|
|
|
326
|
+
# <!-- rdoc-file=vm_eval.c -->
|
|
242
327
|
# Evaluates the string or block in the context of *mod*, except that when a
|
|
243
328
|
# block is given, constant/class variable lookup is not affected. This can be
|
|
244
329
|
# used to add methods to a class. `module_eval` returns the result of evaluating
|
|
@@ -259,8 +344,9 @@ class Module < Object
|
|
|
259
344
|
# or method `code' for Thing:Class
|
|
260
345
|
#
|
|
261
346
|
def class_eval: (String arg0, ?String filename, ?Integer lineno) -> untyped
|
|
262
|
-
| [U] { (self m) -> U } -> U
|
|
347
|
+
| [U] () { (self m) -> U } -> U
|
|
263
348
|
|
|
349
|
+
# <!-- rdoc-file=vm_eval.c -->
|
|
264
350
|
# Evaluates the given block in the context of the class/module. The method
|
|
265
351
|
# defined in the block will belong to the receiver. Any arguments passed to the
|
|
266
352
|
# method will be passed to the block. This can be used if the block needs to
|
|
@@ -279,6 +365,11 @@ class Module < Object
|
|
|
279
365
|
#
|
|
280
366
|
def class_exec: (*untyped args) { () -> untyped } -> untyped
|
|
281
367
|
|
|
368
|
+
# <!--
|
|
369
|
+
# rdoc-file=object.c
|
|
370
|
+
# - obj.class_variable_defined?(symbol) -> true or false
|
|
371
|
+
# - obj.class_variable_defined?(string) -> true or false
|
|
372
|
+
# -->
|
|
282
373
|
# Returns `true` if the given class variable is defined in *obj*. String
|
|
283
374
|
# arguments are converted to symbols.
|
|
284
375
|
#
|
|
@@ -290,6 +381,11 @@ class Module < Object
|
|
|
290
381
|
#
|
|
291
382
|
def class_variable_defined?: (Symbol | String arg0) -> bool
|
|
292
383
|
|
|
384
|
+
# <!--
|
|
385
|
+
# rdoc-file=object.c
|
|
386
|
+
# - mod.class_variable_get(symbol) -> obj
|
|
387
|
+
# - mod.class_variable_get(string) -> obj
|
|
388
|
+
# -->
|
|
293
389
|
# Returns the value of the given class variable (or throws a NameError
|
|
294
390
|
# exception). The `@@` part of the variable name should be included for regular
|
|
295
391
|
# class variables. String arguments are converted to symbols.
|
|
@@ -301,6 +397,11 @@ class Module < Object
|
|
|
301
397
|
#
|
|
302
398
|
def class_variable_get: (Symbol | String arg0) -> untyped
|
|
303
399
|
|
|
400
|
+
# <!--
|
|
401
|
+
# rdoc-file=object.c
|
|
402
|
+
# - obj.class_variable_set(symbol, obj) -> obj
|
|
403
|
+
# - obj.class_variable_set(string, obj) -> obj
|
|
404
|
+
# -->
|
|
304
405
|
# Sets the class variable named by *symbol* to the given object. If the class
|
|
305
406
|
# variable name is passed as a string, that string is converted to a symbol.
|
|
306
407
|
#
|
|
@@ -315,6 +416,10 @@ class Module < Object
|
|
|
315
416
|
#
|
|
316
417
|
def class_variable_set: (Symbol | String arg0, untyped arg1) -> untyped
|
|
317
418
|
|
|
419
|
+
# <!--
|
|
420
|
+
# rdoc-file=object.c
|
|
421
|
+
# - mod.class_variables(inherit=true) -> array
|
|
422
|
+
# -->
|
|
318
423
|
# Returns an array of the names of class variables in *mod*. This includes the
|
|
319
424
|
# names of class variables in any included modules, unless the *inherit*
|
|
320
425
|
# parameter is set to `false`.
|
|
@@ -331,6 +436,11 @@ class Module < Object
|
|
|
331
436
|
#
|
|
332
437
|
def class_variables: (?boolish inherit) -> ::Array[Symbol]
|
|
333
438
|
|
|
439
|
+
# <!--
|
|
440
|
+
# rdoc-file=object.c
|
|
441
|
+
# - mod.const_defined?(sym, inherit=true) -> true or false
|
|
442
|
+
# - mod.const_defined?(str, inherit=true) -> true or false
|
|
443
|
+
# -->
|
|
334
444
|
# Says whether *mod* or its ancestors have a constant with the given name:
|
|
335
445
|
#
|
|
336
446
|
# Float.const_defined?(:EPSILON) #=> true, found in Float itself
|
|
@@ -366,6 +476,11 @@ class Module < Object
|
|
|
366
476
|
#
|
|
367
477
|
def const_defined?: (Symbol | String name, ?boolish inherit) -> bool
|
|
368
478
|
|
|
479
|
+
# <!--
|
|
480
|
+
# rdoc-file=object.c
|
|
481
|
+
# - mod.const_get(sym, inherit=true) -> obj
|
|
482
|
+
# - mod.const_get(str, inherit=true) -> obj
|
|
483
|
+
# -->
|
|
369
484
|
# Checks for a constant with the given name in *mod*. If `inherit` is set, the
|
|
370
485
|
# lookup will also search the ancestors (and `Object` if *mod* is a `Module`).
|
|
371
486
|
#
|
|
@@ -400,6 +515,10 @@ class Module < Object
|
|
|
400
515
|
#
|
|
401
516
|
def const_get: (Symbol | String name, ?boolish inherit) -> untyped
|
|
402
517
|
|
|
518
|
+
# <!--
|
|
519
|
+
# rdoc-file=object.c
|
|
520
|
+
# - mod.const_missing(sym) -> obj
|
|
521
|
+
# -->
|
|
403
522
|
# Invoked when a reference is made to an undefined constant in *mod*. It is
|
|
404
523
|
# passed a symbol for the undefined constant, and returns a value to be used for
|
|
405
524
|
# that constant. The following code is an example of the same:
|
|
@@ -430,6 +549,11 @@ class Module < Object
|
|
|
430
549
|
#
|
|
431
550
|
def const_missing: (Symbol arg0) -> untyped
|
|
432
551
|
|
|
552
|
+
# <!--
|
|
553
|
+
# rdoc-file=object.c
|
|
554
|
+
# - mod.const_set(sym, obj) -> obj
|
|
555
|
+
# - mod.const_set(str, obj) -> obj
|
|
556
|
+
# -->
|
|
433
557
|
# Sets the named constant to the given object, returning that object. Creates a
|
|
434
558
|
# new constant if no constant with the given name previously existed.
|
|
435
559
|
#
|
|
@@ -443,38 +567,47 @@ class Module < Object
|
|
|
443
567
|
#
|
|
444
568
|
def const_set: (Symbol | String arg0, untyped arg1) -> untyped
|
|
445
569
|
|
|
446
|
-
#
|
|
447
|
-
#
|
|
570
|
+
# <!--
|
|
571
|
+
# rdoc-file=object.c
|
|
572
|
+
# - mod.const_source_location(sym, inherit=true) -> [String, Integer]
|
|
573
|
+
# - mod.const_source_location(str, inherit=true) -> [String, Integer]
|
|
574
|
+
# -->
|
|
575
|
+
# Returns the Ruby source filename and line number containing the definition of
|
|
576
|
+
# the constant specified. If the named constant is not found, `nil` is returned.
|
|
448
577
|
# If the constant is found, but its source location can not be extracted
|
|
449
578
|
# (constant is defined in C code), empty array is returned.
|
|
450
579
|
#
|
|
451
580
|
# *inherit* specifies whether to lookup in `mod.ancestors` (`true` by default).
|
|
452
581
|
#
|
|
453
582
|
# # test.rb:
|
|
454
|
-
# class A
|
|
583
|
+
# class A # line 1
|
|
455
584
|
# C1 = 1
|
|
585
|
+
# C2 = 2
|
|
456
586
|
# end
|
|
457
587
|
#
|
|
458
|
-
# module M
|
|
459
|
-
#
|
|
588
|
+
# module M # line 6
|
|
589
|
+
# C3 = 3
|
|
460
590
|
# end
|
|
461
591
|
#
|
|
462
|
-
# class B < A
|
|
592
|
+
# class B < A # line 10
|
|
463
593
|
# include M
|
|
464
|
-
#
|
|
594
|
+
# C4 = 4
|
|
465
595
|
# end
|
|
466
596
|
#
|
|
467
597
|
# class A # continuation of A definition
|
|
598
|
+
# C2 = 8 # constant redefinition; warned yet allowed
|
|
468
599
|
# end
|
|
469
600
|
#
|
|
470
|
-
# p B.const_source_location('
|
|
471
|
-
# p B.const_source_location('
|
|
601
|
+
# p B.const_source_location('C4') # => ["test.rb", 12]
|
|
602
|
+
# p B.const_source_location('C3') # => ["test.rb", 7]
|
|
472
603
|
# p B.const_source_location('C1') # => ["test.rb", 2]
|
|
473
604
|
#
|
|
474
|
-
# p B.const_source_location('
|
|
605
|
+
# p B.const_source_location('C3', false) # => nil -- don't lookup in ancestors
|
|
475
606
|
#
|
|
476
|
-
# p
|
|
477
|
-
#
|
|
607
|
+
# p A.const_source_location('C2') # => ["test.rb", 16] -- actual (last) definition place
|
|
608
|
+
#
|
|
609
|
+
# p Object.const_source_location('B') # => ["test.rb", 10] -- top-level constant could be looked through Object
|
|
610
|
+
# p Object.const_source_location('A') # => ["test.rb", 1] -- class reopening is NOT considered new definition
|
|
478
611
|
#
|
|
479
612
|
# p B.const_source_location('A') # => ["test.rb", 1] -- because Object is in ancestors
|
|
480
613
|
# p M.const_source_location('A') # => ["test.rb", 1] -- Object is not ancestor, but additionally checked for modules
|
|
@@ -482,8 +615,12 @@ class Module < Object
|
|
|
482
615
|
# p Object.const_source_location('A::C1') # => ["test.rb", 2] -- nesting is supported
|
|
483
616
|
# p Object.const_source_location('String') # => [] -- constant is defined in C code
|
|
484
617
|
#
|
|
485
|
-
def const_source_location: (Symbol | String name, ?boolish inherit) -> ([String, Integer] | [ ] | nil)
|
|
618
|
+
def const_source_location: (Symbol | String name, ?boolish inherit) -> ([ String, Integer ] | [ ] | nil)
|
|
486
619
|
|
|
620
|
+
# <!--
|
|
621
|
+
# rdoc-file=object.c
|
|
622
|
+
# - mod.constants(inherit=true) -> array
|
|
623
|
+
# -->
|
|
487
624
|
# Returns an array of the names of the constants accessible in *mod*. This
|
|
488
625
|
# includes the names of constants in any included modules (example at start of
|
|
489
626
|
# section), unless the *inherit* parameter is set to `false`.
|
|
@@ -498,6 +635,11 @@ class Module < Object
|
|
|
498
635
|
#
|
|
499
636
|
def constants: (?boolish inherit) -> ::Array[Symbol]
|
|
500
637
|
|
|
638
|
+
# <!--
|
|
639
|
+
# rdoc-file=proc.c
|
|
640
|
+
# - define_method(symbol, method) -> symbol
|
|
641
|
+
# - define_method(symbol) { block } -> symbol
|
|
642
|
+
# -->
|
|
501
643
|
# Defines an instance method in the receiver. The *method* parameter can be a
|
|
502
644
|
# `Proc`, a `Method` or an `UnboundMethod` object. If a block is specified, it
|
|
503
645
|
# is used as the method body. If a block or the *method* parameter has
|
|
@@ -538,6 +680,10 @@ class Module < Object
|
|
|
538
680
|
|
|
539
681
|
def equal?: (untyped other) -> bool
|
|
540
682
|
|
|
683
|
+
# <!--
|
|
684
|
+
# rdoc-file=eval.c
|
|
685
|
+
# - extend_object(obj) -> obj
|
|
686
|
+
# -->
|
|
541
687
|
# Extends the specified object by adding this module's constants and methods
|
|
542
688
|
# (which are added as singleton methods). This is the callback method used by
|
|
543
689
|
# Object#extend.
|
|
@@ -562,6 +708,10 @@ class Module < Object
|
|
|
562
708
|
#
|
|
563
709
|
def extend_object: (untyped arg0) -> untyped
|
|
564
710
|
|
|
711
|
+
# <!--
|
|
712
|
+
# rdoc-file=object.c
|
|
713
|
+
# - extended(othermod)
|
|
714
|
+
# -->
|
|
565
715
|
# The equivalent of `included`, but for extended modules.
|
|
566
716
|
#
|
|
567
717
|
# module A
|
|
@@ -576,17 +726,30 @@ class Module < Object
|
|
|
576
726
|
#
|
|
577
727
|
def extended: (Module othermod) -> untyped
|
|
578
728
|
|
|
729
|
+
# <!--
|
|
730
|
+
# rdoc-file=object.c
|
|
731
|
+
# - mod.freeze -> mod
|
|
732
|
+
# -->
|
|
579
733
|
# Prevents further modifications to *mod*.
|
|
580
734
|
#
|
|
581
735
|
# This method returns self.
|
|
582
736
|
#
|
|
583
737
|
def freeze: () -> self
|
|
584
738
|
|
|
739
|
+
# <!--
|
|
740
|
+
# rdoc-file=eval.c
|
|
741
|
+
# - include(module, ...) -> self
|
|
742
|
+
# -->
|
|
585
743
|
# Invokes Module.append_features on each parameter in reverse order.
|
|
586
744
|
#
|
|
587
|
-
def
|
|
745
|
+
def include: (*Module arg0) -> self
|
|
588
746
|
|
|
589
|
-
#
|
|
747
|
+
# <!--
|
|
748
|
+
# rdoc-file=object.c
|
|
749
|
+
# - mod.include?(module) -> true or false
|
|
750
|
+
# -->
|
|
751
|
+
# Returns `true` if *module* is included or prepended in *mod* or one of *mod*'s
|
|
752
|
+
# ancestors.
|
|
590
753
|
#
|
|
591
754
|
# module A
|
|
592
755
|
# end
|
|
@@ -601,6 +764,10 @@ class Module < Object
|
|
|
601
764
|
#
|
|
602
765
|
def include?: (Module arg0) -> bool
|
|
603
766
|
|
|
767
|
+
# <!--
|
|
768
|
+
# rdoc-file=object.c
|
|
769
|
+
# - included(othermod)
|
|
770
|
+
# -->
|
|
604
771
|
# Callback invoked whenever the receiver is included in another module or class.
|
|
605
772
|
# This should be used in preference to `Module.append_features` if your code
|
|
606
773
|
# wants to perform some action when a module is included in another.
|
|
@@ -617,20 +784,34 @@ class Module < Object
|
|
|
617
784
|
#
|
|
618
785
|
def included: (Module othermod) -> untyped
|
|
619
786
|
|
|
620
|
-
#
|
|
787
|
+
# <!--
|
|
788
|
+
# rdoc-file=object.c
|
|
789
|
+
# - mod.included_modules -> array
|
|
790
|
+
# -->
|
|
791
|
+
# Returns the list of modules included or prepended in *mod* or one of *mod*'s
|
|
792
|
+
# ancestors.
|
|
793
|
+
#
|
|
794
|
+
# module Sub
|
|
795
|
+
# end
|
|
621
796
|
#
|
|
622
797
|
# module Mixin
|
|
798
|
+
# prepend Sub
|
|
623
799
|
# end
|
|
624
800
|
#
|
|
625
801
|
# module Outer
|
|
626
802
|
# include Mixin
|
|
627
803
|
# end
|
|
628
804
|
#
|
|
629
|
-
# Mixin.included_modules #=> []
|
|
630
|
-
# Outer.included_modules #=> [Mixin]
|
|
805
|
+
# Mixin.included_modules #=> [Sub]
|
|
806
|
+
# Outer.included_modules #=> [Sub, Mixin]
|
|
631
807
|
#
|
|
632
808
|
def included_modules: () -> ::Array[Module]
|
|
633
809
|
|
|
810
|
+
# <!--
|
|
811
|
+
# rdoc-file=object.c
|
|
812
|
+
# - Module.new -> mod
|
|
813
|
+
# - Module.new {|mod| block } -> mod
|
|
814
|
+
# -->
|
|
634
815
|
# Creates a new anonymous module. If a block is given, it is passed the module
|
|
635
816
|
# object, and the block is evaluated in the context of this module like
|
|
636
817
|
# #module_eval.
|
|
@@ -654,6 +835,10 @@ class Module < Object
|
|
|
654
835
|
def initialize: () -> Object
|
|
655
836
|
| () { (Module arg0) -> untyped } -> void
|
|
656
837
|
|
|
838
|
+
# <!--
|
|
839
|
+
# rdoc-file=proc.c
|
|
840
|
+
# - mod.instance_method(symbol) -> unbound_method
|
|
841
|
+
# -->
|
|
657
842
|
# Returns an `UnboundMethod` representing the given instance method in *mod*.
|
|
658
843
|
#
|
|
659
844
|
# class Interpreter
|
|
@@ -681,6 +866,10 @@ class Module < Object
|
|
|
681
866
|
#
|
|
682
867
|
def instance_method: (Symbol arg0) -> UnboundMethod
|
|
683
868
|
|
|
869
|
+
# <!--
|
|
870
|
+
# rdoc-file=object.c
|
|
871
|
+
# - mod.instance_methods(include_super=true) -> array
|
|
872
|
+
# -->
|
|
684
873
|
# Returns an array containing the names of the public and protected instance
|
|
685
874
|
# methods in the receiver. For a module, these are the public and protected
|
|
686
875
|
# methods; for a class, they are the instance (not singleton) methods. If the
|
|
@@ -705,6 +894,10 @@ class Module < Object
|
|
|
705
894
|
#
|
|
706
895
|
def instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
|
707
896
|
|
|
897
|
+
# <!--
|
|
898
|
+
# rdoc-file=object.c
|
|
899
|
+
# - method_added(method_name)
|
|
900
|
+
# -->
|
|
708
901
|
# Invoked as a callback whenever an instance method is added to the receiver.
|
|
709
902
|
#
|
|
710
903
|
# module Chatty
|
|
@@ -721,6 +914,11 @@ class Module < Object
|
|
|
721
914
|
#
|
|
722
915
|
def method_added: (Symbol meth) -> untyped
|
|
723
916
|
|
|
917
|
+
# <!--
|
|
918
|
+
# rdoc-file=vm_method.c
|
|
919
|
+
# - mod.method_defined?(symbol, inherit=true) -> true or false
|
|
920
|
+
# - mod.method_defined?(string, inherit=true) -> true or false
|
|
921
|
+
# -->
|
|
724
922
|
# Returns `true` if the named method is defined by *mod*. If *inherit* is set,
|
|
725
923
|
# the lookup will also search *mod*'s ancestors. Public and protected methods
|
|
726
924
|
# are matched. String arguments are converted to symbols.
|
|
@@ -752,6 +950,10 @@ class Module < Object
|
|
|
752
950
|
#
|
|
753
951
|
def method_defined?: (Symbol | String name, ?boolish inherit) -> bool
|
|
754
952
|
|
|
953
|
+
# <!--
|
|
954
|
+
# rdoc-file=object.c
|
|
955
|
+
# - method_removed(method_name)
|
|
956
|
+
# -->
|
|
755
957
|
# Invoked as a callback whenever an instance method is removed from the
|
|
756
958
|
# receiver.
|
|
757
959
|
#
|
|
@@ -773,6 +975,13 @@ class Module < Object
|
|
|
773
975
|
#
|
|
774
976
|
def method_removed: (Symbol method_name) -> untyped
|
|
775
977
|
|
|
978
|
+
# <!--
|
|
979
|
+
# rdoc-file=vm_eval.c
|
|
980
|
+
# - mod.class_eval(string [, filename [, lineno]]) -> obj
|
|
981
|
+
# - mod.class_eval {|mod| block } -> obj
|
|
982
|
+
# - mod.module_eval(string [, filename [, lineno]]) -> obj
|
|
983
|
+
# - mod.module_eval {|mod| block } -> obj
|
|
984
|
+
# -->
|
|
776
985
|
# Evaluates the string or block in the context of *mod*, except that when a
|
|
777
986
|
# block is given, constant/class variable lookup is not affected. This can be
|
|
778
987
|
# used to add methods to a class. `module_eval` returns the result of evaluating
|
|
@@ -793,8 +1002,13 @@ class Module < Object
|
|
|
793
1002
|
# or method `code' for Thing:Class
|
|
794
1003
|
#
|
|
795
1004
|
def module_eval: (String arg0, ?String filename, ?Integer lineno) -> untyped
|
|
796
|
-
| [U] { (self m) -> U } -> U
|
|
1005
|
+
| [U] () { (self m) -> U } -> U
|
|
797
1006
|
|
|
1007
|
+
# <!--
|
|
1008
|
+
# rdoc-file=vm_eval.c
|
|
1009
|
+
# - mod.module_exec(arg...) {|var...| block } -> obj
|
|
1010
|
+
# - mod.class_exec(arg...) {|var...| block } -> obj
|
|
1011
|
+
# -->
|
|
798
1012
|
# Evaluates the given block in the context of the class/module. The method
|
|
799
1013
|
# defined in the block will belong to the receiver. Any arguments passed to the
|
|
800
1014
|
# method will be passed to the block. This can be used if the block needs to
|
|
@@ -813,12 +1027,21 @@ class Module < Object
|
|
|
813
1027
|
#
|
|
814
1028
|
def module_exec: (*untyped args) { () -> untyped } -> untyped
|
|
815
1029
|
|
|
1030
|
+
# <!--
|
|
1031
|
+
# rdoc-file=vm_method.c
|
|
1032
|
+
# - module_function -> nil
|
|
1033
|
+
# - module_function(method_name) -> method_name
|
|
1034
|
+
# - module_function(method_name, method_name, ...) -> array
|
|
1035
|
+
# -->
|
|
816
1036
|
# Creates module functions for the named methods. These functions may be called
|
|
817
1037
|
# with the module as a receiver, and also become available as instance methods
|
|
818
1038
|
# to classes that mix in the module. Module functions are copies of the
|
|
819
1039
|
# original, and so may be changed independently. The instance-method versions
|
|
820
1040
|
# are made private. If used with no arguments, subsequently defined methods
|
|
821
|
-
# become module functions. String arguments are converted to symbols.
|
|
1041
|
+
# become module functions. String arguments are converted to symbols. If a
|
|
1042
|
+
# single argument is passed, it is returned. If no argument is passed, nil is
|
|
1043
|
+
# returned. If multiple arguments are passed, the arguments are returned as an
|
|
1044
|
+
# array.
|
|
822
1045
|
#
|
|
823
1046
|
# module Mod
|
|
824
1047
|
# def one
|
|
@@ -845,14 +1068,26 @@ class Module < Object
|
|
|
845
1068
|
#
|
|
846
1069
|
def module_function: (*Symbol | String arg0) -> self
|
|
847
1070
|
|
|
1071
|
+
# <!--
|
|
1072
|
+
# rdoc-file=object.c
|
|
1073
|
+
# - mod.name -> string
|
|
1074
|
+
# -->
|
|
848
1075
|
# Returns the name of the module *mod*. Returns nil for anonymous modules.
|
|
849
1076
|
#
|
|
850
1077
|
def name: () -> String?
|
|
851
1078
|
|
|
1079
|
+
# <!--
|
|
1080
|
+
# rdoc-file=eval.c
|
|
1081
|
+
# - prepend(module, ...) -> self
|
|
1082
|
+
# -->
|
|
852
1083
|
# Invokes Module.prepend_features on each parameter in reverse order.
|
|
853
1084
|
#
|
|
854
|
-
def
|
|
1085
|
+
def prepend: (*Module arg0) -> self
|
|
855
1086
|
|
|
1087
|
+
# <!--
|
|
1088
|
+
# rdoc-file=eval.c
|
|
1089
|
+
# - prepend_features(mod) -> mod
|
|
1090
|
+
# -->
|
|
856
1091
|
# When this module is prepended in another, Ruby calls #prepend_features in this
|
|
857
1092
|
# module, passing it the receiving module in *mod*. Ruby's default
|
|
858
1093
|
# implementation is to overlay the constants, methods, and module variables of
|
|
@@ -861,6 +1096,10 @@ class Module < Object
|
|
|
861
1096
|
#
|
|
862
1097
|
def prepend_features: (Module arg0) -> self
|
|
863
1098
|
|
|
1099
|
+
# <!--
|
|
1100
|
+
# rdoc-file=object.c
|
|
1101
|
+
# - prepended(othermod)
|
|
1102
|
+
# -->
|
|
864
1103
|
# The equivalent of `included`, but for prepended modules.
|
|
865
1104
|
#
|
|
866
1105
|
# module A
|
|
@@ -875,9 +1114,19 @@ class Module < Object
|
|
|
875
1114
|
#
|
|
876
1115
|
def prepended: (Module othermod) -> untyped
|
|
877
1116
|
|
|
1117
|
+
# <!--
|
|
1118
|
+
# rdoc-file=vm_method.c
|
|
1119
|
+
# - private -> nil
|
|
1120
|
+
# - private(method_name) -> method_name
|
|
1121
|
+
# - private(method_name, method_name, ...) -> array
|
|
1122
|
+
# - private(array) -> array
|
|
1123
|
+
# -->
|
|
878
1124
|
# With no arguments, sets the default visibility for subsequently defined
|
|
879
1125
|
# methods to private. With arguments, sets the named methods to have private
|
|
880
|
-
# visibility. String arguments are converted to symbols.
|
|
1126
|
+
# visibility. String arguments are converted to symbols. An Array of Symbols
|
|
1127
|
+
# and/or Strings is also accepted. If a single argument is passed, it is
|
|
1128
|
+
# returned. If no argument is passed, nil is returned. If multiple arguments are
|
|
1129
|
+
# passed, the arguments are returned as an array.
|
|
881
1130
|
#
|
|
882
1131
|
# module Mod
|
|
883
1132
|
# def a() end
|
|
@@ -890,12 +1139,23 @@ class Module < Object
|
|
|
890
1139
|
#
|
|
891
1140
|
# Note that to show a private method on RDoc, use `:doc:`.
|
|
892
1141
|
#
|
|
893
|
-
def
|
|
894
|
-
|
|
1142
|
+
def private: () -> nil
|
|
1143
|
+
| (Symbol method_name) -> Symbol
|
|
1144
|
+
| (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
|
|
1145
|
+
| (string method_name) -> string
|
|
1146
|
+
| (string | Symbol, string | Symbol, *string | Symbol method_name) -> Array[string | Symbol]
|
|
1147
|
+
|
|
1148
|
+
# <!--
|
|
1149
|
+
# rdoc-file=vm_method.c
|
|
1150
|
+
# - mod.private_class_method(symbol, ...) -> mod
|
|
1151
|
+
# - mod.private_class_method(string, ...) -> mod
|
|
1152
|
+
# - mod.private_class_method(array) -> mod
|
|
1153
|
+
# -->
|
|
895
1154
|
# Makes existing class methods private. Often used to hide the default
|
|
896
1155
|
# constructor `new`.
|
|
897
1156
|
#
|
|
898
|
-
# String arguments are converted to symbols.
|
|
1157
|
+
# String arguments are converted to symbols. An Array of Symbols and/or Strings
|
|
1158
|
+
# is also accepted.
|
|
899
1159
|
#
|
|
900
1160
|
# class SimpleSingleton # Not thread safe
|
|
901
1161
|
# private_class_method :new
|
|
@@ -907,10 +1167,18 @@ class Module < Object
|
|
|
907
1167
|
#
|
|
908
1168
|
def private_class_method: (*Symbol | String arg0) -> self
|
|
909
1169
|
|
|
1170
|
+
# <!--
|
|
1171
|
+
# rdoc-file=object.c
|
|
1172
|
+
# - mod.private_constant(symbol, ...) => mod
|
|
1173
|
+
# -->
|
|
910
1174
|
# Makes a list of existing constants private.
|
|
911
1175
|
#
|
|
912
1176
|
def private_constant: (*Symbol arg0) -> self
|
|
913
1177
|
|
|
1178
|
+
# <!--
|
|
1179
|
+
# rdoc-file=object.c
|
|
1180
|
+
# - mod.private_instance_methods(include_super=true) -> array
|
|
1181
|
+
# -->
|
|
914
1182
|
# Returns a list of the private instance methods defined in *mod*. If the
|
|
915
1183
|
# optional parameter is `false`, the methods of any ancestors are not included.
|
|
916
1184
|
#
|
|
@@ -924,6 +1192,11 @@ class Module < Object
|
|
|
924
1192
|
#
|
|
925
1193
|
def private_instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
|
926
1194
|
|
|
1195
|
+
# <!--
|
|
1196
|
+
# rdoc-file=vm_method.c
|
|
1197
|
+
# - mod.private_method_defined?(symbol, inherit=true) -> true or false
|
|
1198
|
+
# - mod.private_method_defined?(string, inherit=true) -> true or false
|
|
1199
|
+
# -->
|
|
927
1200
|
# Returns `true` if the named private method is defined by *mod*. If *inherit*
|
|
928
1201
|
# is set, the lookup will also search *mod*'s ancestors. String arguments are
|
|
929
1202
|
# converted to symbols.
|
|
@@ -949,9 +1222,19 @@ class Module < Object
|
|
|
949
1222
|
#
|
|
950
1223
|
def private_method_defined?: (Symbol | String name, ?boolish inherit) -> bool
|
|
951
1224
|
|
|
1225
|
+
# <!--
|
|
1226
|
+
# rdoc-file=vm_method.c
|
|
1227
|
+
# - protected -> nil
|
|
1228
|
+
# - protected(method_name) -> method_name
|
|
1229
|
+
# - protected(method_name, method_name, ...) -> array
|
|
1230
|
+
# - protected(array) -> array
|
|
1231
|
+
# -->
|
|
952
1232
|
# With no arguments, sets the default visibility for subsequently defined
|
|
953
1233
|
# methods to protected. With arguments, sets the named methods to have protected
|
|
954
|
-
# visibility. String arguments are converted to symbols.
|
|
1234
|
+
# visibility. String arguments are converted to symbols. An Array of Symbols
|
|
1235
|
+
# and/or Strings is also accepted. If a single argument is passed, it is
|
|
1236
|
+
# returned. If no argument is passed, nil is returned. If multiple arguments are
|
|
1237
|
+
# passed, the arguments are returned as an array.
|
|
955
1238
|
#
|
|
956
1239
|
# If a method has protected visibility, it is callable only where `self` of the
|
|
957
1240
|
# context is the same as the method. (method definition or instance_eval). This
|
|
@@ -964,11 +1247,20 @@ class Module < Object
|
|
|
964
1247
|
#
|
|
965
1248
|
def protected: (*Symbol | String arg0) -> self
|
|
966
1249
|
|
|
1250
|
+
# <!--
|
|
1251
|
+
# rdoc-file=object.c
|
|
1252
|
+
# - mod.protected_instance_methods(include_super=true) -> array
|
|
1253
|
+
# -->
|
|
967
1254
|
# Returns a list of the protected instance methods defined in *mod*. If the
|
|
968
1255
|
# optional parameter is `false`, the methods of any ancestors are not included.
|
|
969
1256
|
#
|
|
970
1257
|
def protected_instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
|
971
1258
|
|
|
1259
|
+
# <!--
|
|
1260
|
+
# rdoc-file=vm_method.c
|
|
1261
|
+
# - mod.protected_method_defined?(symbol, inherit=true) -> true or false
|
|
1262
|
+
# - mod.protected_method_defined?(string, inherit=true) -> true or false
|
|
1263
|
+
# -->
|
|
972
1264
|
# Returns `true` if the named protected method is defined *mod*. If *inherit*
|
|
973
1265
|
# is set, the lookup will also search *mod*'s ancestors. String arguments are
|
|
974
1266
|
# converted to symbols.
|
|
@@ -994,31 +1286,69 @@ class Module < Object
|
|
|
994
1286
|
#
|
|
995
1287
|
def protected_method_defined?: (Symbol | String name, ?boolish inherit) -> bool
|
|
996
1288
|
|
|
1289
|
+
# <!--
|
|
1290
|
+
# rdoc-file=vm_method.c
|
|
1291
|
+
# - public -> nil
|
|
1292
|
+
# - public(method_name) -> method_name
|
|
1293
|
+
# - public(method_name, method_name, ...) -> array
|
|
1294
|
+
# - public(array) -> array
|
|
1295
|
+
# -->
|
|
997
1296
|
# With no arguments, sets the default visibility for subsequently defined
|
|
998
1297
|
# methods to public. With arguments, sets the named methods to have public
|
|
999
|
-
# visibility. String arguments are converted to symbols.
|
|
1000
|
-
#
|
|
1001
|
-
|
|
1002
|
-
|
|
1298
|
+
# visibility. String arguments are converted to symbols. An Array of Symbols
|
|
1299
|
+
# and/or Strings is also accepted. If a single argument is passed, it is
|
|
1300
|
+
# returned. If no argument is passed, nil is returned. If multiple arguments are
|
|
1301
|
+
# passed, the arguments are returned as an array.
|
|
1302
|
+
#
|
|
1303
|
+
def public: () -> nil
|
|
1304
|
+
| (Symbol method_name) -> Symbol
|
|
1305
|
+
| (Symbol, Symbol, *Symbol method_name) -> Array[Symbol]
|
|
1306
|
+
| (string method_name) -> string
|
|
1307
|
+
| (string | Symbol, string | Symbol, *string | Symbol method_name) -> Array[string | Symbol]
|
|
1308
|
+
|
|
1309
|
+
# <!--
|
|
1310
|
+
# rdoc-file=vm_method.c
|
|
1311
|
+
# - mod.public_class_method(symbol, ...) -> mod
|
|
1312
|
+
# - mod.public_class_method(string, ...) -> mod
|
|
1313
|
+
# - mod.public_class_method(array) -> mod
|
|
1314
|
+
# -->
|
|
1003
1315
|
# Makes a list of existing class methods public.
|
|
1004
1316
|
#
|
|
1005
|
-
# String arguments are converted to symbols.
|
|
1317
|
+
# String arguments are converted to symbols. An Array of Symbols and/or Strings
|
|
1318
|
+
# is also accepted.
|
|
1006
1319
|
#
|
|
1007
1320
|
def public_class_method: (*Symbol | String arg0) -> self
|
|
1008
1321
|
|
|
1322
|
+
# <!--
|
|
1323
|
+
# rdoc-file=object.c
|
|
1324
|
+
# - mod.public_constant(symbol, ...) => mod
|
|
1325
|
+
# -->
|
|
1009
1326
|
# Makes a list of existing constants public.
|
|
1010
1327
|
#
|
|
1011
1328
|
def public_constant: (*Symbol arg0) -> self
|
|
1012
1329
|
|
|
1330
|
+
# <!--
|
|
1331
|
+
# rdoc-file=proc.c
|
|
1332
|
+
# - mod.public_instance_method(symbol) -> unbound_method
|
|
1333
|
+
# -->
|
|
1013
1334
|
# Similar to *instance_method*, searches public method only.
|
|
1014
1335
|
#
|
|
1015
1336
|
def public_instance_method: (Symbol arg0) -> UnboundMethod
|
|
1016
1337
|
|
|
1338
|
+
# <!--
|
|
1339
|
+
# rdoc-file=object.c
|
|
1340
|
+
# - mod.public_instance_methods(include_super=true) -> array
|
|
1341
|
+
# -->
|
|
1017
1342
|
# Returns a list of the public instance methods defined in *mod*. If the
|
|
1018
1343
|
# optional parameter is `false`, the methods of any ancestors are not included.
|
|
1019
1344
|
#
|
|
1020
1345
|
def public_instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
|
1021
1346
|
|
|
1347
|
+
# <!--
|
|
1348
|
+
# rdoc-file=vm_method.c
|
|
1349
|
+
# - mod.public_method_defined?(symbol, inherit=true) -> true or false
|
|
1350
|
+
# - mod.public_method_defined?(string, inherit=true) -> true or false
|
|
1351
|
+
# -->
|
|
1022
1352
|
# Returns `true` if the named public method is defined by *mod*. If *inherit*
|
|
1023
1353
|
# is set, the lookup will also search *mod*'s ancestors. String arguments are
|
|
1024
1354
|
# converted to symbols.
|
|
@@ -1044,18 +1374,26 @@ class Module < Object
|
|
|
1044
1374
|
#
|
|
1045
1375
|
def public_method_defined?: (Symbol | String name, ?boolish inherit) -> bool
|
|
1046
1376
|
|
|
1377
|
+
# <!--
|
|
1378
|
+
# rdoc-file=eval.c
|
|
1379
|
+
# - refine(mod) { block } -> module
|
|
1380
|
+
# -->
|
|
1047
1381
|
# Refine *mod* in the receiver.
|
|
1048
1382
|
#
|
|
1049
1383
|
# Returns a module, where refined methods are defined.
|
|
1050
1384
|
#
|
|
1051
1385
|
def refine: (Class arg0) { (untyped arg0) -> untyped } -> self
|
|
1052
1386
|
|
|
1053
|
-
#
|
|
1387
|
+
# <!--
|
|
1388
|
+
# rdoc-file=object.c
|
|
1389
|
+
# - remove_class_variable(sym) -> obj
|
|
1390
|
+
# -->
|
|
1391
|
+
# Removes the named class variable from the receiver, returning that variable's
|
|
1392
|
+
# value.
|
|
1054
1393
|
#
|
|
1055
|
-
# class
|
|
1394
|
+
# class Example
|
|
1056
1395
|
# @@var = 99
|
|
1057
|
-
# puts
|
|
1058
|
-
# remove_class_variable(:@@var)
|
|
1396
|
+
# puts remove_class_variable(:@@var)
|
|
1059
1397
|
# p(defined? @@var)
|
|
1060
1398
|
# end
|
|
1061
1399
|
#
|
|
@@ -1066,17 +1404,30 @@ class Module < Object
|
|
|
1066
1404
|
#
|
|
1067
1405
|
def remove_class_variable: (Symbol arg0) -> untyped
|
|
1068
1406
|
|
|
1407
|
+
# <!--
|
|
1408
|
+
# rdoc-file=object.c
|
|
1409
|
+
# - remove_const(sym) -> obj
|
|
1410
|
+
# -->
|
|
1069
1411
|
# Removes the definition of the given constant, returning that constant's
|
|
1070
1412
|
# previous value. If that constant referred to a module, this will not change
|
|
1071
1413
|
# that module's name and can lead to confusion.
|
|
1072
1414
|
#
|
|
1073
1415
|
def remove_const: (Symbol arg0) -> untyped
|
|
1074
1416
|
|
|
1417
|
+
# <!--
|
|
1418
|
+
# rdoc-file=vm_method.c
|
|
1419
|
+
# - remove_method(symbol) -> self
|
|
1420
|
+
# - remove_method(string) -> self
|
|
1421
|
+
# -->
|
|
1075
1422
|
# Removes the method identified by *symbol* from the current class. For an
|
|
1076
1423
|
# example, see Module#undef_method. String arguments are converted to symbols.
|
|
1077
1424
|
#
|
|
1078
1425
|
def remove_method: (*Symbol | String arg0) -> self
|
|
1079
1426
|
|
|
1427
|
+
# <!--
|
|
1428
|
+
# rdoc-file=object.c
|
|
1429
|
+
# - mod.singleton_class? -> true or false
|
|
1430
|
+
# -->
|
|
1080
1431
|
# Returns `true` if *mod* is a singleton class or `false` if it is an ordinary
|
|
1081
1432
|
# class or module.
|
|
1082
1433
|
#
|
|
@@ -1087,12 +1438,21 @@ class Module < Object
|
|
|
1087
1438
|
#
|
|
1088
1439
|
def singleton_class?: () -> bool
|
|
1089
1440
|
|
|
1441
|
+
# <!--
|
|
1442
|
+
# rdoc-file=object.c
|
|
1443
|
+
# - mod.to_s -> string
|
|
1444
|
+
# -->
|
|
1090
1445
|
# Returns a string representing this module or class. For basic classes and
|
|
1091
1446
|
# modules, this is the name. For singletons, we show information on the thing
|
|
1092
1447
|
# we're attached to as well.
|
|
1093
1448
|
#
|
|
1094
1449
|
def to_s: () -> String
|
|
1095
1450
|
|
|
1451
|
+
# <!--
|
|
1452
|
+
# rdoc-file=vm_method.c
|
|
1453
|
+
# - undef_method(symbol) -> self
|
|
1454
|
+
# - undef_method(string) -> self
|
|
1455
|
+
# -->
|
|
1096
1456
|
# Prevents the current class from responding to calls to the named method.
|
|
1097
1457
|
# Contrast this with `remove_method`, which deletes the method from the
|
|
1098
1458
|
# particular class; Ruby will still search superclasses and mixed-in modules for
|
|
@@ -1130,16 +1490,32 @@ class Module < Object
|
|
|
1130
1490
|
#
|
|
1131
1491
|
def undef_method: (*Symbol | String arg0) -> self
|
|
1132
1492
|
|
|
1493
|
+
# <!--
|
|
1494
|
+
# rdoc-file=eval.c
|
|
1495
|
+
# - using(module) -> self
|
|
1496
|
+
# -->
|
|
1133
1497
|
# Import class refinements from *module* into the current class or module
|
|
1134
1498
|
# definition.
|
|
1135
1499
|
#
|
|
1136
1500
|
def using: (Module arg0) -> self
|
|
1137
1501
|
|
|
1502
|
+
# <!-- rdoc-file=object.c -->
|
|
1503
|
+
# Returns a string representing this module or class. For basic classes and
|
|
1504
|
+
# modules, this is the name. For singletons, we show information on the thing
|
|
1505
|
+
# we're attached to as well.
|
|
1506
|
+
#
|
|
1138
1507
|
def inspect: () -> String
|
|
1139
1508
|
|
|
1509
|
+
# <!--
|
|
1510
|
+
# rdoc-file=object.c
|
|
1511
|
+
# - attr(name, ...) -> array
|
|
1512
|
+
# - attr(name, true) -> array
|
|
1513
|
+
# - attr(name, false) -> array
|
|
1514
|
+
# -->
|
|
1140
1515
|
# The first form is equivalent to #attr_reader. The second form is equivalent to
|
|
1141
1516
|
# `attr_accessor(name)` but deprecated. The last form is equivalent to
|
|
1142
|
-
# `attr_reader(name)` but deprecated.
|
|
1517
|
+
# `attr_reader(name)` but deprecated. Returns an array of defined method names
|
|
1518
|
+
# as symbols.
|
|
1143
1519
|
#
|
|
1144
1520
|
def attr: (*Symbol | String arg0) -> NilClass
|
|
1145
1521
|
end
|