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/basic_object.rbs
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# <!-- rdoc-file=object.c -->
|
1
2
|
# BasicObject is the parent class of all classes in Ruby. It's an explicit
|
2
3
|
# blank class.
|
3
4
|
#
|
@@ -24,7 +25,7 @@
|
|
24
25
|
# DELEGATE = [:puts, :p]
|
25
26
|
#
|
26
27
|
# def method_missing(name, *args, &block)
|
27
|
-
# super unless DELEGATE.include? name
|
28
|
+
# return super unless DELEGATE.include? name
|
28
29
|
# ::Kernel.send(name, *args, &block)
|
29
30
|
# end
|
30
31
|
#
|
@@ -44,21 +45,79 @@
|
|
44
45
|
# end
|
45
46
|
# end
|
46
47
|
#
|
48
|
+
# ### What's Here
|
49
|
+
#
|
50
|
+
# These are the methods defined for BasicObject:
|
51
|
+
#
|
52
|
+
# ::new
|
53
|
+
# : Returns a new BasicObject instance.
|
54
|
+
#
|
55
|
+
# [!](#method-i-21)
|
56
|
+
# : Returns the boolean negation of `self`: `true` or `false`.
|
57
|
+
#
|
58
|
+
# [!=](#method-i-21-3D)
|
59
|
+
# : Returns whether `self` and the given object are *not* equal.
|
60
|
+
#
|
61
|
+
# [==](#method-i-3D-3D)
|
62
|
+
# : Returns whether `self` and the given object are equivalent.
|
63
|
+
#
|
64
|
+
# [__id__](#method-i-__id__)
|
65
|
+
# : Returns the integer object identifier for `self`.
|
66
|
+
#
|
67
|
+
# [__send__](#method-i-__send__)
|
68
|
+
# : Calls the method identified by the given symbol.
|
69
|
+
#
|
70
|
+
# #equal?
|
71
|
+
# : Returns whether `self` and the given object are the same object.
|
72
|
+
#
|
73
|
+
# #instance_eval
|
74
|
+
# : Evaluates the given string or block in the context of `self`.
|
75
|
+
#
|
76
|
+
# #instance_exec
|
77
|
+
# : Executes the given block in the context of `self`, passing the given
|
78
|
+
# arguments.
|
79
|
+
#
|
80
|
+
# #method_missing
|
81
|
+
# : Method called when an undefined method is called on `self`.
|
82
|
+
#
|
83
|
+
# #singleton_method_added
|
84
|
+
# : Method called when a singleton method is added to `self`.
|
85
|
+
#
|
86
|
+
# #singleton_method_removed
|
87
|
+
# : Method called when a singleton method is added removed from `self`.
|
88
|
+
#
|
89
|
+
# #singleton_method_undefined
|
90
|
+
# : Method called when a singleton method is undefined in `self`.
|
91
|
+
#
|
47
92
|
class BasicObject
|
93
|
+
# <!--
|
94
|
+
# rdoc-file=object.c
|
95
|
+
# - !obj -> true or false
|
96
|
+
# -->
|
48
97
|
# Boolean negate.
|
49
98
|
#
|
50
99
|
def !: () -> bool
|
51
100
|
|
101
|
+
# <!--
|
102
|
+
# rdoc-file=object.c
|
103
|
+
# - obj != other -> true or false
|
104
|
+
# -->
|
52
105
|
# Returns true if two objects are not-equal, otherwise false.
|
53
106
|
#
|
54
107
|
def !=: (untyped other) -> bool
|
55
108
|
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
109
|
+
# <!--
|
110
|
+
# rdoc-file=object.c
|
111
|
+
# - obj == other -> true or false
|
112
|
+
# - obj.equal?(other) -> true or false
|
113
|
+
# - obj.eql?(other) -> true or false
|
114
|
+
# -->
|
115
|
+
# Equality --- At the Object level, #== returns `true` only if `obj` and `other`
|
116
|
+
# are the same object. Typically, this method is overridden in descendant
|
117
|
+
# classes to provide class-specific meaning.
|
118
|
+
#
|
119
|
+
# Unlike #==, the #equal? method should never be overridden by subclasses as it
|
120
|
+
# is used to determine object identity (that is, `a.equal?(b)` if and only if
|
62
121
|
# `a` is the same object as `b`):
|
63
122
|
#
|
64
123
|
# obj = "a"
|
@@ -68,18 +127,27 @@ class BasicObject
|
|
68
127
|
# obj.equal? other #=> false
|
69
128
|
# obj.equal? obj #=> true
|
70
129
|
#
|
71
|
-
# The
|
72
|
-
# key. This is used by Hash to test members for equality. For
|
73
|
-
# `
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
130
|
+
# The #eql? method returns `true` if `obj` and `other` refer to the same hash
|
131
|
+
# key. This is used by Hash to test members for equality. For any pair of
|
132
|
+
# objects where #eql? returns `true`, the #hash value of both objects must be
|
133
|
+
# equal. So any subclass that overrides #eql? should also override #hash
|
134
|
+
# appropriately.
|
135
|
+
#
|
136
|
+
# For objects of class Object, #eql? is synonymous with #==. Subclasses
|
137
|
+
# normally continue this tradition by aliasing #eql? to their overridden #==
|
138
|
+
# method, but there are exceptions. Numeric types, for example, perform type
|
139
|
+
# conversion across #==, but not across #eql?, so:
|
77
140
|
#
|
78
141
|
# 1 == 1.0 #=> true
|
79
142
|
# 1.eql? 1.0 #=> false
|
80
143
|
#
|
81
144
|
def ==: (untyped other) -> bool
|
82
145
|
|
146
|
+
# <!--
|
147
|
+
# rdoc-file=gc.c
|
148
|
+
# - obj.__id__ -> integer
|
149
|
+
# - obj.object_id -> integer
|
150
|
+
# -->
|
83
151
|
# Returns an integer identifier for `obj`.
|
84
152
|
#
|
85
153
|
# The same number will be returned on all calls to `object_id` for a given
|
@@ -88,6 +156,8 @@ class BasicObject
|
|
88
156
|
# Note: that some objects of builtin classes are reused for optimization. This
|
89
157
|
# is the case for immediate values and frozen string literals.
|
90
158
|
#
|
159
|
+
# BasicObject implements +__id__+, Kernel implements `object_id`.
|
160
|
+
#
|
91
161
|
# Immediate values are not passed by reference but are passed by value: `nil`,
|
92
162
|
# `true`, `false`, Fixnums, Symbols, and some Floats.
|
93
163
|
#
|
@@ -98,11 +168,21 @@ class BasicObject
|
|
98
168
|
#
|
99
169
|
def __id__: () -> Integer
|
100
170
|
|
171
|
+
# <!--
|
172
|
+
# rdoc-file=vm_eval.c
|
173
|
+
# - foo.send(symbol [, args...]) -> obj
|
174
|
+
# - foo.__send__(symbol [, args...]) -> obj
|
175
|
+
# - foo.send(string [, args...]) -> obj
|
176
|
+
# - foo.__send__(string [, args...]) -> obj
|
177
|
+
# -->
|
101
178
|
# Invokes the method identified by *symbol*, passing it any arguments specified.
|
102
|
-
#
|
103
|
-
# *obj*. When the method is identified by a string, the string is converted to a
|
179
|
+
# When the method is identified by a string, the string is converted to a
|
104
180
|
# symbol.
|
105
181
|
#
|
182
|
+
# BasicObject implements +__send__+, Kernel implements `send`. `__send__` is
|
183
|
+
# safer than `send` when *obj* has the same method name like `Socket`. See also
|
184
|
+
# `public_send`.
|
185
|
+
#
|
106
186
|
# class Klass
|
107
187
|
# def hello(*args)
|
108
188
|
# "Hello " + args.join(' ')
|
@@ -113,12 +193,13 @@ class BasicObject
|
|
113
193
|
#
|
114
194
|
def __send__: (String | Symbol arg0, *untyped args) -> untyped
|
115
195
|
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
196
|
+
# <!-- rdoc-file=object.c -->
|
197
|
+
# Equality --- At the Object level, #== returns `true` only if `obj` and `other`
|
198
|
+
# are the same object. Typically, this method is overridden in descendant
|
199
|
+
# classes to provide class-specific meaning.
|
119
200
|
#
|
120
|
-
# Unlike
|
121
|
-
#
|
201
|
+
# Unlike #==, the #equal? method should never be overridden by subclasses as it
|
202
|
+
# is used to determine object identity (that is, `a.equal?(b)` if and only if
|
122
203
|
# `a` is the same object as `b`):
|
123
204
|
#
|
124
205
|
# obj = "a"
|
@@ -128,18 +209,27 @@ class BasicObject
|
|
128
209
|
# obj.equal? other #=> false
|
129
210
|
# obj.equal? obj #=> true
|
130
211
|
#
|
131
|
-
# The
|
132
|
-
# key. This is used by Hash to test members for equality. For
|
133
|
-
# `
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
212
|
+
# The #eql? method returns `true` if `obj` and `other` refer to the same hash
|
213
|
+
# key. This is used by Hash to test members for equality. For any pair of
|
214
|
+
# objects where #eql? returns `true`, the #hash value of both objects must be
|
215
|
+
# equal. So any subclass that overrides #eql? should also override #hash
|
216
|
+
# appropriately.
|
217
|
+
#
|
218
|
+
# For objects of class Object, #eql? is synonymous with #==. Subclasses
|
219
|
+
# normally continue this tradition by aliasing #eql? to their overridden #==
|
220
|
+
# method, but there are exceptions. Numeric types, for example, perform type
|
221
|
+
# conversion across #==, but not across #eql?, so:
|
137
222
|
#
|
138
223
|
# 1 == 1.0 #=> true
|
139
224
|
# 1.eql? 1.0 #=> false
|
140
225
|
#
|
141
226
|
def equal?: (untyped other) -> bool
|
142
227
|
|
228
|
+
# <!--
|
229
|
+
# rdoc-file=vm_eval.c
|
230
|
+
# - obj.instance_eval(string [, filename [, lineno]] ) -> obj
|
231
|
+
# - obj.instance_eval {|obj| block } -> obj
|
232
|
+
# -->
|
143
233
|
# Evaluates a string containing Ruby source code, or the given block, within the
|
144
234
|
# context of the receiver (*obj*). In order to set the context, the variable
|
145
235
|
# `self` is set to *obj* while the code is executing, giving the code access to
|
@@ -169,6 +259,10 @@ class BasicObject
|
|
169
259
|
def instance_eval: (String, ?String filename, ?Integer lineno) -> untyped
|
170
260
|
| [U] () { (self) -> U } -> U
|
171
261
|
|
262
|
+
# <!--
|
263
|
+
# rdoc-file=vm_eval.c
|
264
|
+
# - obj.instance_exec(arg...) {|var...| block } -> obj
|
265
|
+
# -->
|
172
266
|
# Executes the given block within the context of the receiver (*obj*). In order
|
173
267
|
# to set the context, the variable `self` is set to *obj* while the code is
|
174
268
|
# executing, giving the code access to *obj*'s instance variables. Arguments
|
@@ -184,12 +278,20 @@ class BasicObject
|
|
184
278
|
#
|
185
279
|
def instance_exec: [U, V] (*V args) { (*V args) -> U } -> U
|
186
280
|
|
187
|
-
#
|
281
|
+
# <!--
|
282
|
+
# rdoc-file=object.c
|
283
|
+
# - BasicObject.new
|
284
|
+
# -->
|
285
|
+
# Returns a new BasicObject.
|
188
286
|
#
|
189
287
|
def initialize: () -> void
|
190
288
|
|
191
289
|
private
|
192
290
|
|
291
|
+
# <!--
|
292
|
+
# rdoc-file=vm_eval.c
|
293
|
+
# - obj.method_missing(symbol [, *args] ) -> result
|
294
|
+
# -->
|
193
295
|
# Invoked by Ruby when *obj* is sent a message it cannot handle. *symbol* is the
|
194
296
|
# symbol for the method called, and *args* are any arguments that were passed to
|
195
297
|
# it. By default, the interpreter raises an error when this method is called.
|
@@ -204,9 +306,14 @@ class BasicObject
|
|
204
306
|
# def roman_to_int(str)
|
205
307
|
# # ...
|
206
308
|
# end
|
207
|
-
#
|
208
|
-
#
|
209
|
-
#
|
309
|
+
#
|
310
|
+
# def method_missing(symbol, *args)
|
311
|
+
# str = symbol.id2name
|
312
|
+
# begin
|
313
|
+
# roman_to_int(str)
|
314
|
+
# rescue
|
315
|
+
# super(symbol, *args)
|
316
|
+
# end
|
210
317
|
# end
|
211
318
|
# end
|
212
319
|
#
|
@@ -214,9 +321,14 @@ class BasicObject
|
|
214
321
|
# r.iv #=> 4
|
215
322
|
# r.xxiii #=> 23
|
216
323
|
# r.mm #=> 2000
|
324
|
+
# r.foo #=> NoMethodError
|
217
325
|
#
|
218
326
|
def method_missing: (Symbol, *untyped, **untyped) ?{ (*untyped, **untyped) -> untyped } -> untyped
|
219
327
|
|
328
|
+
# <!--
|
329
|
+
# rdoc-file=object.c
|
330
|
+
# - singleton_method_added(symbol)
|
331
|
+
# -->
|
220
332
|
# Invoked as a callback whenever a singleton method is added to the receiver.
|
221
333
|
#
|
222
334
|
# module Chatty
|
@@ -236,6 +348,10 @@ class BasicObject
|
|
236
348
|
#
|
237
349
|
def singleton_method_added: (Symbol) -> void
|
238
350
|
|
351
|
+
# <!--
|
352
|
+
# rdoc-file=object.c
|
353
|
+
# - singleton_method_removed(symbol)
|
354
|
+
# -->
|
239
355
|
# Invoked as a callback whenever a singleton method is removed from the
|
240
356
|
# receiver.
|
241
357
|
#
|
@@ -259,6 +375,10 @@ class BasicObject
|
|
259
375
|
#
|
260
376
|
def singleton_method_removed: (Symbol) -> void
|
261
377
|
|
378
|
+
# <!--
|
379
|
+
# rdoc-file=object.c
|
380
|
+
# - singleton_method_undefined(symbol)
|
381
|
+
# -->
|
262
382
|
# Invoked as a callback whenever a singleton method is undefined in the
|
263
383
|
# receiver.
|
264
384
|
#
|
data/core/binding.rbs
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# <!-- rdoc-file=proc.c -->
|
1
2
|
# Objects of class Binding encapsulate the execution context at some particular
|
2
3
|
# place in the code and retain this context for future use. The variables,
|
3
4
|
# methods, value of `self`, and possibly an iterator block that can be accessed
|
@@ -33,6 +34,10 @@ class Binding
|
|
33
34
|
|
34
35
|
def clone: () -> self
|
35
36
|
|
37
|
+
# <!--
|
38
|
+
# rdoc-file=proc.c
|
39
|
+
# - binding.eval(string [, filename [,lineno]]) -> obj
|
40
|
+
# -->
|
36
41
|
# Evaluates the Ruby expression(s) in *string*, in the *binding*'s context. If
|
37
42
|
# the optional *filename* and *lineno* parameters are present, they will be used
|
38
43
|
# when reporting syntax errors.
|
@@ -45,6 +50,10 @@ class Binding
|
|
45
50
|
#
|
46
51
|
def eval: (String arg0, ?String filename, ?Integer lineno) -> untyped
|
47
52
|
|
53
|
+
# <!--
|
54
|
+
# rdoc-file=lib/irb.rb
|
55
|
+
# - irb()
|
56
|
+
# -->
|
48
57
|
# Opens an IRB session where `binding.irb` is called which allows for
|
49
58
|
# interactive debugging. You can call any methods or variables available in the
|
50
59
|
# current scope, and mutate state if you need to.
|
@@ -103,6 +112,10 @@ class Binding
|
|
103
112
|
#
|
104
113
|
def irb: () -> void
|
105
114
|
|
115
|
+
# <!--
|
116
|
+
# rdoc-file=proc.c
|
117
|
+
# - binding.local_variable_defined?(symbol) -> obj
|
118
|
+
# -->
|
106
119
|
# Returns `true` if a local variable `symbol` exists.
|
107
120
|
#
|
108
121
|
# def foo
|
@@ -117,6 +130,10 @@ class Binding
|
|
117
130
|
#
|
118
131
|
def local_variable_defined?: (String | Symbol symbol) -> bool
|
119
132
|
|
133
|
+
# <!--
|
134
|
+
# rdoc-file=proc.c
|
135
|
+
# - binding.local_variable_get(symbol) -> obj
|
136
|
+
# -->
|
120
137
|
# Returns the value of the local variable `symbol`.
|
121
138
|
#
|
122
139
|
# def foo
|
@@ -131,6 +148,10 @@ class Binding
|
|
131
148
|
#
|
132
149
|
def local_variable_get: (String | Symbol symbol) -> untyped
|
133
150
|
|
151
|
+
# <!--
|
152
|
+
# rdoc-file=proc.c
|
153
|
+
# - binding.local_variable_set(symbol, obj) -> obj
|
154
|
+
# -->
|
134
155
|
# Set local variable named `symbol` as `obj`.
|
135
156
|
#
|
136
157
|
# def foo
|
@@ -154,6 +175,10 @@ class Binding
|
|
154
175
|
#
|
155
176
|
def local_variable_set: [U] (String | Symbol symbol, U obj) -> U
|
156
177
|
|
178
|
+
# <!--
|
179
|
+
# rdoc-file=proc.c
|
180
|
+
# - binding.local_variables -> Array
|
181
|
+
# -->
|
157
182
|
# Returns the names of the binding's local variables as symbols.
|
158
183
|
#
|
159
184
|
# def foo
|
@@ -169,10 +194,18 @@ class Binding
|
|
169
194
|
#
|
170
195
|
def local_variables: () -> Array[Symbol]
|
171
196
|
|
197
|
+
# <!--
|
198
|
+
# rdoc-file=proc.c
|
199
|
+
# - binding.receiver -> object
|
200
|
+
# -->
|
172
201
|
# Returns the bound receiver of the binding object.
|
173
202
|
#
|
174
203
|
def receiver: () -> untyped
|
175
204
|
|
205
|
+
# <!--
|
206
|
+
# rdoc-file=proc.c
|
207
|
+
# - binding.source_location -> [String, Integer]
|
208
|
+
# -->
|
176
209
|
# Returns the Ruby source filename and line number of the binding object.
|
177
210
|
#
|
178
211
|
def source_location: () -> [ String, Integer ]
|
data/core/builtin.rbs
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
interface _ToI
|
2
|
-
def to_i: -> Integer
|
2
|
+
def to_i: () -> Integer
|
3
3
|
end
|
4
4
|
|
5
5
|
interface _ToInt
|
6
|
-
def to_int: -> Integer
|
6
|
+
def to_int: () -> Integer
|
7
7
|
end
|
8
8
|
|
9
9
|
interface _ToR
|
@@ -11,7 +11,7 @@ interface _ToR
|
|
11
11
|
end
|
12
12
|
|
13
13
|
interface _ToS
|
14
|
-
def to_s: -> String
|
14
|
+
def to_s: () -> String
|
15
15
|
end
|
16
16
|
|
17
17
|
interface _ToStr
|
@@ -31,7 +31,7 @@ interface _ToPath
|
|
31
31
|
end
|
32
32
|
|
33
33
|
interface _Each[out A]
|
34
|
-
def each: { (A) -> void } -> void
|
34
|
+
def each: () { (A) -> void } -> void
|
35
35
|
end
|
36
36
|
|
37
37
|
interface _Reader
|
data/core/class.rbs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# <!-- rdoc-file=object.c -->
|
2
2
|
# Classes in Ruby are first-class objects---each is an instance of class Class.
|
3
3
|
#
|
4
4
|
# Typically, you create a new class by using:
|
@@ -52,7 +52,13 @@
|
|
52
52
|
# | |
|
53
53
|
# obj--->OtherClass---------->(OtherClass)-----------...
|
54
54
|
#
|
55
|
+
%a{annotate:rdoc:source:from=object.c}
|
55
56
|
class Class < Module
|
57
|
+
# <!--
|
58
|
+
# rdoc-file=object.c
|
59
|
+
# - Class.new(super_class=Object) -> a_class
|
60
|
+
# - Class.new(super_class=Object) { |mod| ... } -> a_class
|
61
|
+
# -->
|
56
62
|
# Creates a new anonymous (unnamed) class with the given superclass (or Object
|
57
63
|
# if no parameter is given). You can give a class a name by assigning the class
|
58
64
|
# object to a constant.
|
@@ -78,6 +84,10 @@ class Class < Module
|
|
78
84
|
#
|
79
85
|
def initialize: (?Class superclass) ?{ (Class newclass) -> void } -> void
|
80
86
|
|
87
|
+
# <!--
|
88
|
+
# rdoc-file=object.c
|
89
|
+
# - class.allocate() -> obj
|
90
|
+
# -->
|
81
91
|
# Allocates space for a new object of *class*'s class and does not call
|
82
92
|
# initialize on the new instance. The returned object must be an instance of
|
83
93
|
# *class*.
|
@@ -96,6 +106,10 @@ class Class < Module
|
|
96
106
|
#
|
97
107
|
def allocate: () -> untyped
|
98
108
|
|
109
|
+
# <!--
|
110
|
+
# rdoc-file=object.c
|
111
|
+
# - inherited(subclass)
|
112
|
+
# -->
|
99
113
|
# Callback invoked whenever a subclass of the current class is created.
|
100
114
|
#
|
101
115
|
# Example:
|
@@ -119,12 +133,39 @@ class Class < Module
|
|
119
133
|
#
|
120
134
|
def inherited: (Class arg0) -> untyped
|
121
135
|
|
136
|
+
# <!--
|
137
|
+
# rdoc-file=object.c
|
138
|
+
# - class.new(args, ...) -> obj
|
139
|
+
# -->
|
122
140
|
# Calls #allocate to create a new object of *class*'s class, then invokes that
|
123
141
|
# object's #initialize method, passing it *args*. This is the method that ends
|
124
142
|
# up getting called whenever an object is constructed using `.new`.
|
125
143
|
#
|
126
144
|
def new: () -> untyped
|
127
145
|
|
146
|
+
# <!--
|
147
|
+
# rdoc-file=object.c
|
148
|
+
# - subclasses -> array
|
149
|
+
# -->
|
150
|
+
# Returns an array of classes where the receiver is the direct superclass of the
|
151
|
+
# class, excluding singleton classes. The order of the returned array is not
|
152
|
+
# defined.
|
153
|
+
#
|
154
|
+
# class A; end
|
155
|
+
# class B < A; end
|
156
|
+
# class C < B; end
|
157
|
+
# class D < A; end
|
158
|
+
#
|
159
|
+
# A.subclasses #=> [D, B]
|
160
|
+
# B.subclasses #=> [C]
|
161
|
+
# C.subclasses #=> []
|
162
|
+
#
|
163
|
+
def subclasses: () -> Array[Class]
|
164
|
+
|
165
|
+
# <!--
|
166
|
+
# rdoc-file=object.c
|
167
|
+
# - class.superclass -> a_super_class or nil
|
168
|
+
# -->
|
128
169
|
# Returns the superclass of *class*, or `nil`.
|
129
170
|
#
|
130
171
|
# File.superclass #=> IO
|
@@ -138,8 +179,5 @@ class Class < Module
|
|
138
179
|
#
|
139
180
|
# BasicObject.superclass #=> nil
|
140
181
|
#
|
141
|
-
|
142
|
-
# class.superclass -> a_super_class or nil
|
143
|
-
#
|
144
|
-
def `superclass`: () -> Class?
|
182
|
+
def superclass: () -> Class?
|
145
183
|
end
|
data/core/comparable.rbs
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# <!-- rdoc-file=compar.c -->
|
1
2
|
# The Comparable mixin is used by classes whose objects may be ordered. The
|
2
3
|
# class must define the `<=>` operator, which compares the receiver against
|
3
4
|
# another object, returning a value less than 0, returning 0, or returning a
|
@@ -32,32 +33,83 @@
|
|
32
33
|
# s4.between?(s3, s5) #=> true
|
33
34
|
# [ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV]
|
34
35
|
#
|
36
|
+
# ## What's Here
|
37
|
+
#
|
38
|
+
# Module Comparable provides these methods, all of which use method `<=>`:
|
39
|
+
#
|
40
|
+
# [<](#method-i-3C)
|
41
|
+
# : Returns whether `self` is less than the given object.
|
42
|
+
#
|
43
|
+
# [<=](#method-i-3C-3D)
|
44
|
+
# : Returns whether `self` is less than or equal to the given object.
|
45
|
+
#
|
46
|
+
# [==](#method-i-3D-3D)
|
47
|
+
# : Returns whether `self` is equal to the given object.
|
48
|
+
#
|
49
|
+
# [>](#method-i-3E)
|
50
|
+
# : Returns whether `self` is greater than or equal to the given object.
|
51
|
+
#
|
52
|
+
# [>=](#method-i-3E-3D)
|
53
|
+
# : Returns whether `self` is greater than the given object.
|
54
|
+
#
|
55
|
+
# * #between? Returns `true` if `self` is between two given objects.
|
56
|
+
# #clamp
|
57
|
+
# : For given objects `min` and `max`, or range `(min..max)`, returns:
|
58
|
+
#
|
59
|
+
# * `min` if `(self <=> min) < 0`.
|
60
|
+
# * `max` if `(self <=> max) > 0`.
|
61
|
+
# * `self` otherwise.
|
62
|
+
#
|
35
63
|
module Comparable : _WithSpaceshipOperator
|
64
|
+
# <!--
|
65
|
+
# rdoc-file=compar.c
|
66
|
+
# - obj < other -> true or false
|
67
|
+
# -->
|
36
68
|
# Compares two objects based on the receiver's `<=>` method, returning true if
|
37
69
|
# it returns a value less than 0.
|
38
70
|
#
|
39
71
|
def <: (untyped other) -> bool
|
40
72
|
|
73
|
+
# <!--
|
74
|
+
# rdoc-file=compar.c
|
75
|
+
# - obj <= other -> true or false
|
76
|
+
# -->
|
41
77
|
# Compares two objects based on the receiver's `<=>` method, returning true if
|
42
78
|
# it returns a value less than or equal to 0.
|
43
79
|
#
|
44
80
|
def <=: (untyped other) -> bool
|
45
81
|
|
82
|
+
# <!--
|
83
|
+
# rdoc-file=compar.c
|
84
|
+
# - obj == other -> true or false
|
85
|
+
# -->
|
46
86
|
# Compares two objects based on the receiver's `<=>` method, returning true if
|
47
87
|
# it returns 0. Also returns true if *obj* and *other* are the same object.
|
48
88
|
#
|
49
89
|
def ==: (untyped other) -> bool
|
50
90
|
|
91
|
+
# <!--
|
92
|
+
# rdoc-file=compar.c
|
93
|
+
# - obj > other -> true or false
|
94
|
+
# -->
|
51
95
|
# Compares two objects based on the receiver's `<=>` method, returning true if
|
52
96
|
# it returns a value greater than 0.
|
53
97
|
#
|
54
98
|
def >: (untyped other) -> bool
|
55
99
|
|
100
|
+
# <!--
|
101
|
+
# rdoc-file=compar.c
|
102
|
+
# - obj >= other -> true or false
|
103
|
+
# -->
|
56
104
|
# Compares two objects based on the receiver's `<=>` method, returning true if
|
57
105
|
# it returns a value greater than or equal to 0.
|
58
106
|
#
|
59
107
|
def >=: (untyped other) -> bool
|
60
108
|
|
109
|
+
# <!--
|
110
|
+
# rdoc-file=compar.c
|
111
|
+
# - obj.between?(min, max) -> true or false
|
112
|
+
# -->
|
61
113
|
# Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max*
|
62
114
|
# is greater than zero, `true` otherwise.
|
63
115
|
#
|
@@ -68,6 +120,11 @@ module Comparable : _WithSpaceshipOperator
|
|
68
120
|
#
|
69
121
|
def between?: (untyped min, untyped max) -> bool
|
70
122
|
|
123
|
+
# <!--
|
124
|
+
# rdoc-file=compar.c
|
125
|
+
# - obj.clamp(min, max) -> obj
|
126
|
+
# - obj.clamp(range) -> obj
|
127
|
+
# -->
|
71
128
|
# In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero,
|
72
129
|
# *max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise.
|
73
130
|
#
|