rbs 3.4.0.pre.1 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +1 -1
- data/CHANGELOG.md +21 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/Rakefile +2 -2
- data/core/complex.rbs +290 -177
- data/core/dir.rbs +22 -9
- data/core/errors.rbs +1 -5
- data/core/file.rbs +152 -37
- data/core/float.rbs +4 -6
- data/core/gc.rbs +1 -0
- data/core/io/buffer.rbs +126 -47
- data/core/io.rbs +24 -5
- data/core/kernel.rbs +3 -3
- data/core/match_data.rbs +24 -14
- data/core/module.rbs +23 -18
- data/core/numeric.rbs +13 -16
- data/core/object_space/weak_key_map.rbs +78 -11
- data/core/object_space.rbs +2 -0
- data/core/process.rbs +4 -3
- data/core/range.rbs +10 -9
- data/core/refinement.rbs +10 -1
- data/core/string.rbs +24 -25
- data/core/thread.rbs +4 -4
- data/core/trace_point.rbs +7 -4
- data/docs/gem.md +58 -0
- data/lib/rbs/test/errors.rb +6 -1
- data/lib/rbs/version.rb +1 -1
- data/stdlib/bigdecimal/0/big_decimal.rbs +28 -29
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +6 -6
- data/stdlib/pty/0/pty.rbs +1 -7
- data/stdlib/socket/0/addrinfo.rbs +4 -0
- data/stdlib/socket/0/basic_socket.rbs +4 -2
- data/stdlib/socket/0/socket.rbs +4 -3
- data/stdlib/socket/0/udp_socket.rbs +4 -2
- metadata +4 -3
@@ -1,10 +1,62 @@
|
|
1
1
|
%a{annotate:rdoc:skip}
|
2
2
|
module ObjectSpace
|
3
3
|
# <!-- rdoc-file=weakmap.c -->
|
4
|
-
# An ObjectSpace::WeakKeyMap
|
5
|
-
#
|
4
|
+
# An ObjectSpace::WeakKeyMap is a key-value map that holds weak references to
|
5
|
+
# its keys, so they can be garbage collected when there is no more references.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# Unlike ObjectSpace::WeakMap:
|
8
|
+
#
|
9
|
+
# * references to values are *strong*, so they aren't garbage collected while
|
10
|
+
# they are in the map;
|
11
|
+
# * keys are compared by value (using Object#eql?), not by identity;
|
12
|
+
# * only garbage-collectable objects can be used as keys.
|
13
|
+
#
|
14
|
+
# map = ObjectSpace::WeakKeyMap.new
|
15
|
+
# val = Time.new(2023, 12, 7)
|
16
|
+
# key = "name"
|
17
|
+
# map[key] = val
|
18
|
+
#
|
19
|
+
# # Value is fetched by equality: the instance of string "name" is
|
20
|
+
# # different here, but it is equal to the key
|
21
|
+
# map["name"] #=> 2023-12-07 00:00:00 +0200
|
22
|
+
#
|
23
|
+
# val = nil
|
24
|
+
# GC.start
|
25
|
+
# # There is no more references to `val`, yet the pair isn't
|
26
|
+
# # garbage-collected.
|
27
|
+
# map["name"] #=> 2023-12-07 00:00:00 +0200
|
28
|
+
#
|
29
|
+
# key = nil
|
30
|
+
# GC.start
|
31
|
+
# # There is no more references to `key`, key and value are
|
32
|
+
# # garbage-collected.
|
33
|
+
# map["name"] #=> nil
|
34
|
+
#
|
35
|
+
#
|
36
|
+
# (Note that GC.start is used here only for demonstrational purposes and might
|
37
|
+
# not always lead to demonstrated results.)
|
38
|
+
#
|
39
|
+
# The collection is especially useful for implementing caches of lightweight
|
40
|
+
# value objects, so that only one copy of each value representation would be
|
41
|
+
# stored in memory, but the copies that aren't used would be garbage-collected.
|
42
|
+
#
|
43
|
+
# CACHE = ObjectSpace::WeakKeyMap
|
44
|
+
#
|
45
|
+
# def make_value(**)
|
46
|
+
# val = ValueObject.new(**)
|
47
|
+
# if (existing = @cache.getkey(val))
|
48
|
+
# # if the object with this value exists, we return it
|
49
|
+
# existing
|
50
|
+
# else
|
51
|
+
# # otherwise, put it in the cache
|
52
|
+
# @cache[val] = true
|
53
|
+
# val
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# This will result in `make_value` returning the same object for same set of
|
58
|
+
# attributes always, but the values that aren't needed anymore woudn't be
|
59
|
+
# sitting in the cache forever.
|
8
60
|
#
|
9
61
|
class WeakKeyMap[Key, Value]
|
10
62
|
public
|
@@ -23,7 +75,7 @@ module ObjectSpace
|
|
23
75
|
# rdoc-file=weakmap.c
|
24
76
|
# - map[key] = value -> value
|
25
77
|
# -->
|
26
|
-
# Associates the given `value` with the given `key
|
78
|
+
# Associates the given `value` with the given `key`
|
27
79
|
#
|
28
80
|
# The reference to `key` is weak, so when there is no other reference to `key`
|
29
81
|
# it may be garbage collected.
|
@@ -51,7 +103,8 @@ module ObjectSpace
|
|
51
103
|
# If no block is given and `key` is found, deletes the entry and returns the
|
52
104
|
# associated value:
|
53
105
|
# m = ObjectSpace::WeakKeyMap.new
|
54
|
-
#
|
106
|
+
# key = "foo" # to hold reference to the key
|
107
|
+
# m[key] = 1
|
55
108
|
# m.delete("foo") # => 1
|
56
109
|
# m["foo"] # => nil
|
57
110
|
#
|
@@ -60,13 +113,14 @@ module ObjectSpace
|
|
60
113
|
# If a block is given and `key` is found, ignores the block, deletes the entry,
|
61
114
|
# and returns the associated value:
|
62
115
|
# m = ObjectSpace::WeakKeyMap.new
|
63
|
-
#
|
64
|
-
#
|
116
|
+
# key = "foo" # to hold reference to the key
|
117
|
+
# m[key] = 2
|
118
|
+
# m.delete("foo") { |key| raise 'Will never happen'} # => 2
|
65
119
|
#
|
66
|
-
# If a block is given and `key` is not found,
|
67
|
-
# block's return value:
|
120
|
+
# If a block is given and `key` is not found, yields the `key` to the block and
|
121
|
+
# returns the block's return value:
|
68
122
|
# m = ObjectSpace::WeakKeyMap.new
|
69
|
-
#
|
123
|
+
# m.delete("nosuch") { |key| "Key #{key} not found" } # => "Key nosuch not found"
|
70
124
|
#
|
71
125
|
def delete: (Key) -> Value?
|
72
126
|
| [T] (Key) { (Key) -> T } -> (Value | T)
|
@@ -77,6 +131,19 @@ module ObjectSpace
|
|
77
131
|
# -->
|
78
132
|
# Returns the existing equal key if it exists, otherwise returns `nil`.
|
79
133
|
#
|
134
|
+
# This might be useful for implementing caches, so that only one copy of some
|
135
|
+
# object would be used everywhere in the program:
|
136
|
+
#
|
137
|
+
# value = {amount: 1, currency: 'USD'}
|
138
|
+
#
|
139
|
+
# # Now if we put this object in a cache:
|
140
|
+
# cache = ObjectSpace::WeakKeyMap.new
|
141
|
+
# cache[value] = true
|
142
|
+
#
|
143
|
+
# # ...we can always extract from there and use the same object:
|
144
|
+
# copy = cache.getkey({amount: 1, currency: 'USD'})
|
145
|
+
# copy.object_id == value.object_id #=> true
|
146
|
+
#
|
80
147
|
def getkey: (untyped) -> Key?
|
81
148
|
|
82
149
|
# <!--
|
@@ -93,7 +160,7 @@ module ObjectSpace
|
|
93
160
|
|
94
161
|
# <!--
|
95
162
|
# rdoc-file=weakmap.c
|
96
|
-
# -
|
163
|
+
# - map.key?(key) -> true or false
|
97
164
|
# -->
|
98
165
|
# Returns `true` if `key` is a key in `self`, otherwise `false`.
|
99
166
|
#
|
data/core/object_space.rbs
CHANGED
@@ -166,6 +166,7 @@ module ObjectSpace
|
|
166
166
|
# rdoc-file=gc.rb
|
167
167
|
# - garbage_collect(full_mark: true, immediate_mark: true, immediate_sweep: true)
|
168
168
|
# -->
|
169
|
+
# Alias of GC.start
|
169
170
|
#
|
170
171
|
def self.garbage_collect: (?full_mark: bool, ?immediate_mark: bool, ?immediate_sweep: bool) -> void
|
171
172
|
|
@@ -183,6 +184,7 @@ module ObjectSpace
|
|
183
184
|
# rdoc-file=gc.rb
|
184
185
|
# - garbage_collect(full_mark: true, immediate_mark: true, immediate_sweep: true)
|
185
186
|
# -->
|
187
|
+
# Alias of GC.start
|
186
188
|
#
|
187
189
|
def garbage_collect: (?full_mark: bool, ?immediate_mark: bool, ?immediate_sweep: bool) -> void
|
188
190
|
end
|
data/core/process.rbs
CHANGED
@@ -1788,7 +1788,6 @@ end
|
|
1788
1788
|
# stat = $? # => #<Process::Status: pid 1262862 exit 99>
|
1789
1789
|
# stat.class # => Process::Status
|
1790
1790
|
# stat.to_i # => 25344
|
1791
|
-
# stat >> 8 # => 99
|
1792
1791
|
# stat.stopped? # => false
|
1793
1792
|
# stat.exited? # => true
|
1794
1793
|
# stat.exitstatus # => 99
|
@@ -1798,7 +1797,8 @@ class Process::Status < Object
|
|
1798
1797
|
# rdoc-file=process.c
|
1799
1798
|
# - stat & mask -> integer
|
1800
1799
|
# -->
|
1801
|
-
# This method is deprecated; use
|
1800
|
+
# This method is deprecated as #to_i value is system-specific; use predicate
|
1801
|
+
# methods like #exited? or #stopped?, or getters like #exitstatus or #stopsig.
|
1802
1802
|
#
|
1803
1803
|
# Returns the logical AND of the value of #to_i with `mask`:
|
1804
1804
|
#
|
@@ -1828,7 +1828,8 @@ class Process::Status < Object
|
|
1828
1828
|
# rdoc-file=process.c
|
1829
1829
|
# - stat >> places -> integer
|
1830
1830
|
# -->
|
1831
|
-
# This method is deprecated; use
|
1831
|
+
# This method is deprecated as #to_i value is system-specific; use predicate
|
1832
|
+
# methods like #exited? or #stopped?, or getters like #exitstatus or #stopsig.
|
1832
1833
|
#
|
1833
1834
|
# Returns the value of #to_i, shifted `places` to the right:
|
1834
1835
|
#
|
data/core/range.rbs
CHANGED
@@ -871,15 +871,16 @@ class Range[out Elem] < Object
|
|
871
871
|
# (1..2).overlap?(3..4) # => false
|
872
872
|
# (1...3).overlap?(3..4) # => false
|
873
873
|
#
|
874
|
-
#
|
875
|
-
#
|
876
|
-
#
|
877
|
-
#
|
878
|
-
#
|
879
|
-
#
|
880
|
-
#
|
881
|
-
#
|
882
|
-
#
|
874
|
+
# Note that the method wouldn't make any assumptions about the beginless range
|
875
|
+
# being actually empty, even if its upper bound is the minimum possible value of
|
876
|
+
# its type, so all this would return `true`:
|
877
|
+
#
|
878
|
+
# (...-Float::INFINITY).overlap?(...-Float::INFINITY) # => true
|
879
|
+
# (..."").overlap?(..."") # => true
|
880
|
+
# (...[]).overlap?(...[]) # => true
|
881
|
+
#
|
882
|
+
# Even if those ranges are effectively empty (no number can be smaller than
|
883
|
+
# `-Float::INFINITY`), they are still considered overlapping with themselves.
|
883
884
|
#
|
884
885
|
# Related: Range#cover?.
|
885
886
|
#
|
data/core/refinement.rbs
CHANGED
@@ -46,15 +46,24 @@ class Refinement < Module
|
|
46
46
|
# rdoc-file=eval.c
|
47
47
|
# - refined_class -> class
|
48
48
|
# -->
|
49
|
+
# Deprecated; prefer #target.
|
50
|
+
#
|
49
51
|
# Return the class refined by the receiver.
|
50
52
|
#
|
51
53
|
def refined_class: () -> Module
|
52
54
|
|
53
55
|
# <!--
|
54
56
|
# rdoc-file=eval.c
|
55
|
-
# - target ->
|
57
|
+
# - target -> class_or_module
|
56
58
|
# -->
|
57
59
|
# Return the class or module refined by the receiver.
|
58
60
|
#
|
61
|
+
# module M
|
62
|
+
# refine String do
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# M.refinements[0].target # => String
|
67
|
+
#
|
59
68
|
def target: () -> Module
|
60
69
|
end
|
data/core/string.rbs
CHANGED
@@ -3163,31 +3163,30 @@ class String
|
|
3163
3163
|
|
3164
3164
|
# <!--
|
3165
3165
|
# rdoc-file=complex.c
|
3166
|
-
# -
|
3167
|
-
# -->
|
3168
|
-
# Returns
|
3169
|
-
#
|
3170
|
-
#
|
3171
|
-
#
|
3172
|
-
# '
|
3173
|
-
# '2.5'.to_c
|
3174
|
-
# '2
|
3175
|
-
# '-
|
3176
|
-
# '
|
3177
|
-
# '
|
3178
|
-
# '
|
3179
|
-
# '-
|
3180
|
-
# '
|
3181
|
-
# '1
|
3182
|
-
#
|
3183
|
-
#
|
3184
|
-
#
|
3185
|
-
#
|
3186
|
-
#
|
3187
|
-
#
|
3188
|
-
#
|
3189
|
-
#
|
3190
|
-
# See Kernel.Complex.
|
3166
|
+
# - to_c -> complex
|
3167
|
+
# -->
|
3168
|
+
# Returns `self` interpreted as a Complex object; leading whitespace and
|
3169
|
+
# trailing garbage are ignored:
|
3170
|
+
#
|
3171
|
+
# '9'.to_c # => (9+0i)
|
3172
|
+
# '2.5'.to_c # => (2.5+0i)
|
3173
|
+
# '2.5/1'.to_c # => ((5/2)+0i)
|
3174
|
+
# '-3/2'.to_c # => ((-3/2)+0i)
|
3175
|
+
# '-i'.to_c # => (0-1i)
|
3176
|
+
# '45i'.to_c # => (0+45i)
|
3177
|
+
# '3-4i'.to_c # => (3-4i)
|
3178
|
+
# '-4e2-4e-2i'.to_c # => (-400.0-0.04i)
|
3179
|
+
# '-0.0-0.0i'.to_c # => (-0.0-0.0i)
|
3180
|
+
# '1/2+3/4i'.to_c # => ((1/2)+(3/4)*i)
|
3181
|
+
# '1.0@0'.to_c # => (1+0.0i)
|
3182
|
+
# "1.0@#{Math::PI/2}".to_c # => (0.0+1i)
|
3183
|
+
# "1.0@#{Math::PI}".to_c # => (-1+0.0i)
|
3184
|
+
#
|
3185
|
+
# Returns Complex zero if the string cannot be converted:
|
3186
|
+
#
|
3187
|
+
# 'ruby'.to_c # => (0+0i)
|
3188
|
+
#
|
3189
|
+
# See Kernel#Complex.
|
3191
3190
|
#
|
3192
3191
|
def to_c: () -> Complex
|
3193
3192
|
|
data/core/thread.rbs
CHANGED
@@ -1626,8 +1626,8 @@ class Thread::Queue < Object
|
|
1626
1626
|
# rdoc-file=thread_sync.c
|
1627
1627
|
# - freeze
|
1628
1628
|
# -->
|
1629
|
-
#
|
1630
|
-
# Queue.new.freeze # Raises TypeError (cannot freeze #<Thread::Queue:0x...>)
|
1629
|
+
# The queue can't be frozen, so this method raises an exception:
|
1630
|
+
# Thread::Queue.new.freeze # Raises TypeError (cannot freeze #<Thread::Queue:0x...>)
|
1631
1631
|
#
|
1632
1632
|
def freeze: () -> bot
|
1633
1633
|
|
@@ -1711,8 +1711,8 @@ class Thread::SizedQueue < Thread::Queue
|
|
1711
1711
|
# rdoc-file=thread_sync.c
|
1712
1712
|
# - freeze
|
1713
1713
|
# -->
|
1714
|
-
#
|
1715
|
-
# Queue.new.freeze # Raises TypeError (cannot freeze #<Thread::Queue:0x...>)
|
1714
|
+
# The queue can't be frozen, so this method raises an exception:
|
1715
|
+
# Thread::Queue.new.freeze # Raises TypeError (cannot freeze #<Thread::Queue:0x...>)
|
1716
1716
|
#
|
1717
1717
|
def freeze: () -> bot
|
1718
1718
|
|
data/core/trace_point.rbs
CHANGED
@@ -44,6 +44,8 @@
|
|
44
44
|
# : return from a C-language routine
|
45
45
|
# `:raise`
|
46
46
|
# : raise an exception
|
47
|
+
# `:rescue`
|
48
|
+
# : rescue an exception
|
47
49
|
# `:b_call`
|
48
50
|
# : event hook at block entry
|
49
51
|
# `:b_return`
|
@@ -205,7 +207,7 @@ class TracePoint < Object
|
|
205
207
|
# -->
|
206
208
|
# Return the generated binding object from event.
|
207
209
|
#
|
208
|
-
# Note that for
|
210
|
+
# Note that for `:c_call` and `:c_return` events, the method will return `nil`,
|
209
211
|
# since C methods themselves do not have bindings.
|
210
212
|
#
|
211
213
|
def binding: () -> Binding?
|
@@ -416,7 +418,8 @@ class TracePoint < Object
|
|
416
418
|
# rdoc-file=trace_point.rb
|
417
419
|
# - raised_exception()
|
418
420
|
# -->
|
419
|
-
# Value from exception raised on the `:raise` event
|
421
|
+
# Value from exception raised on the `:raise` event, or rescued on the `:rescue`
|
422
|
+
# event.
|
420
423
|
#
|
421
424
|
def raised_exception: () -> untyped
|
422
425
|
|
@@ -424,7 +427,7 @@ class TracePoint < Object
|
|
424
427
|
# rdoc-file=trace_point.rb
|
425
428
|
# - return_value()
|
426
429
|
# -->
|
427
|
-
# Return value from `:return`,
|
430
|
+
# Return value from `:return`, `:c_return`, and `:b_return` event
|
428
431
|
#
|
429
432
|
def return_value: () -> untyped
|
430
433
|
|
@@ -435,7 +438,7 @@ class TracePoint < Object
|
|
435
438
|
# Return the trace object during event
|
436
439
|
#
|
437
440
|
# Same as the following, except it returns the correct object (the method
|
438
|
-
# receiver) for
|
441
|
+
# receiver) for `:c_call` and `:c_return` events:
|
439
442
|
#
|
440
443
|
# trace.binding.eval('self')
|
441
444
|
#
|
data/docs/gem.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Releasing a gem with RBS
|
2
|
+
|
3
|
+
You can release the RBS type definition of your gem included in the gem package. Just add your RBS files inside `/sig` directory, put them in your rubygem package, and release a new version. RBS gem will load the RBS files from your gem package automatically.
|
4
|
+
|
5
|
+
## `/sig` directory
|
6
|
+
|
7
|
+
RBS gem tries to load a type definition of a gem from gem package first. It checks if there is `/sig` directory in the gem package and loads `*.rbs` files from the directory. So, everything you have to do to make your type definition available are:
|
8
|
+
|
9
|
+
1. Add `/sig` directory in your gem package
|
10
|
+
2. Put your RBS files inside the directory
|
11
|
+
3. Make sure the RBS files are included in the gem package
|
12
|
+
|
13
|
+
### Hidden RBS files
|
14
|
+
|
15
|
+
If you have RBS files you don't want to export to the gem users, you can put the files under a directory that starts with `_``.
|
16
|
+
|
17
|
+
Assume you have three RBS files in your gem package:
|
18
|
+
|
19
|
+
* `/sig/foo.rbs`
|
20
|
+
* `/sig/bar/baz.rbs`
|
21
|
+
* `/sig/_private/internal.rbs`
|
22
|
+
|
23
|
+
`foo.rbs` and `baz.rbs` will be loaded from the gem package, but the `internal.rbs` will be skipped. This is only when you load RBS files of a *library*, for example through `-r` option given to `rbs` command. If you load RBS files as *source code*, for example through `-I` option given to `rbs` command, the hidden RBS files will be loaded too.
|
24
|
+
|
25
|
+
* `rbs -r your-gem` => Loading a library
|
26
|
+
* `rbs -I sig` => Loading RBS files as source code
|
27
|
+
|
28
|
+
### Adding `manifest.yaml`
|
29
|
+
|
30
|
+
`manifest.yaml` lets you declare dependencies to standard libraries. Here is an example, from [RBS gem](https://github.com/ruby/rbs/blob/6b3d0f976a50b3974d0bff26ea8fa9931053f38b/sig/manifest.yaml).
|
31
|
+
|
32
|
+
```yaml
|
33
|
+
dependencies:
|
34
|
+
- name: abbrev
|
35
|
+
- name: json
|
36
|
+
- name: logger
|
37
|
+
- name: optparse
|
38
|
+
- name: pathname
|
39
|
+
- name: rdoc
|
40
|
+
- name: tsort
|
41
|
+
```
|
42
|
+
|
43
|
+
Note that you don't have to write the dependencies that are included in your `.gemspec`. RBS will detect the dependencies between gems, declared in `.gemspec`. `manifest.yaml` is a material for undeclared dependencies, which usually is for standard libraries.
|
44
|
+
|
45
|
+
## Testing your type definition
|
46
|
+
|
47
|
+
If you develop your gem using a static type checker, like [Steep](https://github.com/soutaro/steep), your type definition will be (mostly) correct and reliable. If not, we strongly recommend adding extra tests focusing on the RBS type definitions.
|
48
|
+
|
49
|
+
`RBS::UnitTest` is a library to do that. `assert_send_type` is the most important assertion.
|
50
|
+
|
51
|
+
```rb
|
52
|
+
assert_send_type '(Regexp) { (String) -> String } -> String',
|
53
|
+
'hello', :gsub, /hello/, &proc { "foo" }
|
54
|
+
```
|
55
|
+
|
56
|
+
It calls `String#gsub` method and confirms if given arguments and the return value has correct types.
|
57
|
+
|
58
|
+
You can find examples under `test/stdlib` directory of [RBS repository](https://github.com/ruby/rbs/blob/6b3d0f976a50b3974d0bff26ea8fa9931053f38b/test/stdlib/String_test.rb).
|
data/lib/rbs/test/errors.rb
CHANGED
@@ -41,7 +41,12 @@ module RBS
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.to_string(error)
|
44
|
-
|
44
|
+
name = if error.klass.singleton_class?
|
45
|
+
inspect_(error.klass).sub(/\A#<Class:(.*)>\z/, '\1')
|
46
|
+
else
|
47
|
+
error.klass.name
|
48
|
+
end
|
49
|
+
method = "#{name}#{error.method_name}"
|
45
50
|
case error
|
46
51
|
when ArgumentTypeError
|
47
52
|
"[#{method}] ArgumentTypeError: expected #{format_param error.param} but given `#{inspect_(error.value)}`"
|
data/lib/rbs/version.rb
CHANGED
@@ -1711,61 +1711,60 @@ class Complex
|
|
1711
1711
|
|
1712
1712
|
# <!--
|
1713
1713
|
# rdoc-file=complex.c
|
1714
|
-
# -
|
1715
|
-
# - cmp.quo(numeric) -> complex
|
1714
|
+
# - complex / numeric -> new_complex
|
1716
1715
|
# -->
|
1717
|
-
#
|
1716
|
+
# Returns the quotient of `self` and `numeric`:
|
1718
1717
|
#
|
1719
|
-
# Complex(2, 3) / Complex(2, 3)
|
1720
|
-
# Complex(900) / Complex(1)
|
1721
|
-
# Complex(-2, 9) / Complex(-9, 2)
|
1722
|
-
# Complex(9, 8) / 4
|
1723
|
-
# Complex(20, 9) / 9.8
|
1718
|
+
# Complex(2, 3) / Complex(2, 3) # => ((1/1)+(0/1)*i)
|
1719
|
+
# Complex(900) / Complex(1) # => ((900/1)+(0/1)*i)
|
1720
|
+
# Complex(-2, 9) / Complex(-9, 2) # => ((36/85)-(77/85)*i)
|
1721
|
+
# Complex(9, 8) / 4 # => ((9/4)+(2/1)*i)
|
1722
|
+
# Complex(20, 9) / 9.8 # => (2.0408163265306123+0.9183673469387754i)
|
1724
1723
|
#
|
1725
1724
|
def /: (BigDecimal) -> Complex
|
1726
1725
|
| ...
|
1727
1726
|
|
1728
1727
|
# <!--
|
1729
1728
|
# rdoc-file=complex.c
|
1730
|
-
# -
|
1729
|
+
# - complex * numeric -> new_complex
|
1731
1730
|
# -->
|
1732
|
-
#
|
1731
|
+
# Returns the product of `self` and `numeric`:
|
1733
1732
|
#
|
1734
|
-
# Complex(2, 3) * Complex(2, 3)
|
1735
|
-
# Complex(900) * Complex(1)
|
1736
|
-
# Complex(-2, 9) * Complex(-9, 2)
|
1737
|
-
# Complex(9, 8) * 4
|
1738
|
-
# Complex(20, 9) * 9.8
|
1733
|
+
# Complex(2, 3) * Complex(2, 3) # => (-5+12i)
|
1734
|
+
# Complex(900) * Complex(1) # => (900+0i)
|
1735
|
+
# Complex(-2, 9) * Complex(-9, 2) # => (0-85i)
|
1736
|
+
# Complex(9, 8) * 4 # => (36+32i)
|
1737
|
+
# Complex(20, 9) * 9.8 # => (196.0+88.2i)
|
1739
1738
|
#
|
1740
1739
|
def *: (BigDecimal) -> Complex
|
1741
1740
|
| ...
|
1742
1741
|
|
1743
1742
|
# <!--
|
1744
1743
|
# rdoc-file=complex.c
|
1745
|
-
# -
|
1744
|
+
# - complex + numeric -> new_complex
|
1746
1745
|
# -->
|
1747
|
-
#
|
1746
|
+
# Returns the sum of `self` and `numeric`:
|
1748
1747
|
#
|
1749
|
-
# Complex(2, 3) + Complex(2, 3)
|
1750
|
-
# Complex(900) + Complex(1)
|
1751
|
-
# Complex(-2, 9) + Complex(-9, 2)
|
1752
|
-
# Complex(9, 8) + 4
|
1753
|
-
# Complex(20, 9) + 9.8
|
1748
|
+
# Complex(2, 3) + Complex(2, 3) # => (4+6i)
|
1749
|
+
# Complex(900) + Complex(1) # => (901+0i)
|
1750
|
+
# Complex(-2, 9) + Complex(-9, 2) # => (-11+11i)
|
1751
|
+
# Complex(9, 8) + 4 # => (13+8i)
|
1752
|
+
# Complex(20, 9) + 9.8 # => (29.8+9i)
|
1754
1753
|
#
|
1755
1754
|
def +: (BigDecimal) -> Complex
|
1756
1755
|
| ...
|
1757
1756
|
|
1758
1757
|
# <!--
|
1759
1758
|
# rdoc-file=complex.c
|
1760
|
-
# -
|
1759
|
+
# - complex - numeric -> new_complex
|
1761
1760
|
# -->
|
1762
|
-
#
|
1761
|
+
# Returns the difference of `self` and `numeric`:
|
1763
1762
|
#
|
1764
|
-
# Complex(2, 3) - Complex(2, 3)
|
1765
|
-
# Complex(900) - Complex(1)
|
1766
|
-
# Complex(-2, 9) - Complex(-9, 2)
|
1767
|
-
# Complex(9, 8) - 4
|
1768
|
-
# Complex(20, 9) - 9.8
|
1763
|
+
# Complex(2, 3) - Complex(2, 3) # => (0+0i)
|
1764
|
+
# Complex(900) - Complex(1) # => (899+0i)
|
1765
|
+
# Complex(-2, 9) - Complex(-9, 2) # => (7+7i)
|
1766
|
+
# Complex(9, 8) - 4 # => (5+8i)
|
1767
|
+
# Complex(20, 9) - 9.8 # => (10.2+9i)
|
1769
1768
|
#
|
1770
1769
|
def -: (BigDecimal) -> Complex
|
1771
1770
|
| ...
|
@@ -39,7 +39,7 @@ module Minitest::Test::LifecycleHooks
|
|
39
39
|
# include MyMinitestPlugin
|
40
40
|
# end
|
41
41
|
#
|
42
|
-
def before_setup: () ->
|
42
|
+
def before_setup: () -> void
|
43
43
|
|
44
44
|
# <!--
|
45
45
|
# rdoc-file=lib/minitest/test.rb
|
@@ -47,7 +47,7 @@ module Minitest::Test::LifecycleHooks
|
|
47
47
|
# -->
|
48
48
|
# Runs before every test. Use this to set up before each test run.
|
49
49
|
#
|
50
|
-
def setup: () ->
|
50
|
+
def setup: () -> void
|
51
51
|
|
52
52
|
# <!--
|
53
53
|
# rdoc-file=lib/minitest/test.rb
|
@@ -58,7 +58,7 @@ module Minitest::Test::LifecycleHooks
|
|
58
58
|
#
|
59
59
|
# See #before_setup for an example.
|
60
60
|
#
|
61
|
-
def after_setup: () ->
|
61
|
+
def after_setup: () -> void
|
62
62
|
|
63
63
|
# <!--
|
64
64
|
# rdoc-file=lib/minitest/test.rb
|
@@ -69,7 +69,7 @@ module Minitest::Test::LifecycleHooks
|
|
69
69
|
#
|
70
70
|
# See #before_setup for an example.
|
71
71
|
#
|
72
|
-
def before_teardown: () ->
|
72
|
+
def before_teardown: () -> void
|
73
73
|
|
74
74
|
# <!--
|
75
75
|
# rdoc-file=lib/minitest/test.rb
|
@@ -77,7 +77,7 @@ module Minitest::Test::LifecycleHooks
|
|
77
77
|
# -->
|
78
78
|
# Runs after every test. Use this to clean up after each test run.
|
79
79
|
#
|
80
|
-
def teardown: () ->
|
80
|
+
def teardown: () -> void
|
81
81
|
|
82
82
|
# <!--
|
83
83
|
# rdoc-file=lib/minitest/test.rb
|
@@ -88,5 +88,5 @@ module Minitest::Test::LifecycleHooks
|
|
88
88
|
#
|
89
89
|
# See #before_setup for an example.
|
90
90
|
#
|
91
|
-
def after_teardown: () ->
|
91
|
+
def after_teardown: () -> void
|
92
92
|
end
|
data/stdlib/pty/0/pty.rbs
CHANGED
@@ -74,13 +74,7 @@ module PTY
|
|
74
74
|
#
|
75
75
|
def self.check: (Integer pid, ?boolish raise) -> Process::Status?
|
76
76
|
|
77
|
-
# <!--
|
78
|
-
# rdoc-file=ext/pty/pty.c
|
79
|
-
# - PTY.spawn([env,] command_line) { |r, w, pid| ... }
|
80
|
-
# - PTY.spawn([env,] command_line) => [r, w, pid]
|
81
|
-
# - PTY.spawn([env,] command, arguments, ...) { |r, w, pid| ... }
|
82
|
-
# - PTY.spawn([env,] command, arguments, ...) => [r, w, pid]
|
83
|
-
# -->
|
77
|
+
# <!-- rdoc-file=ext/pty/pty.c -->
|
84
78
|
# Spawns the specified command on a newly allocated pty. You can also use the
|
85
79
|
# alias ::getpty.
|
86
80
|
#
|
@@ -293,8 +293,10 @@ class BasicSocket < IO
|
|
293
293
|
# is set for the underlying file descriptor. *flags* is zero or more of the
|
294
294
|
# `MSG_` options. The result, *mesg*, is the data received.
|
295
295
|
#
|
296
|
-
# When recvfrom(2) returns 0, Socket#recv_nonblock returns
|
297
|
-
#
|
296
|
+
# When recvfrom(2) returns 0, Socket#recv_nonblock returns nil. In most cases it
|
297
|
+
# means the connection was closed, but for UDP connections it may mean an empty
|
298
|
+
# packet was received, as the underlying API makes it impossible to distinguish
|
299
|
+
# these two cases.
|
298
300
|
#
|
299
301
|
# ### Parameters
|
300
302
|
# * `maxlen` - the number of bytes to receive from the socket
|
data/stdlib/socket/0/socket.rbs
CHANGED
@@ -1289,9 +1289,10 @@ class Socket < BasicSocket
|
|
1289
1289
|
# received. The second element, *sender_addrinfo*, contains protocol-specific
|
1290
1290
|
# address information of the sender.
|
1291
1291
|
#
|
1292
|
-
# When recvfrom(2) returns 0, Socket#
|
1293
|
-
#
|
1294
|
-
#
|
1292
|
+
# When recvfrom(2) returns 0, Socket#recv_nonblock returns nil. In most cases it
|
1293
|
+
# means the connection was closed, but for UDP connections it may mean an empty
|
1294
|
+
# packet was received, as the underlying API makes it impossible to distinguish
|
1295
|
+
# these two cases.
|
1295
1296
|
#
|
1296
1297
|
# ### Parameters
|
1297
1298
|
# * `maxlen` - the maximum number of bytes to receive from the socket
|
@@ -44,8 +44,10 @@ class UDPSocket < IPSocket
|
|
44
44
|
# received. The second element, *sender_inet_addr*, is an array to represent the
|
45
45
|
# sender address.
|
46
46
|
#
|
47
|
-
# When recvfrom(2) returns 0, Socket#
|
48
|
-
#
|
47
|
+
# When recvfrom(2) returns 0, Socket#recv_nonblock returns nil. In most cases it
|
48
|
+
# means the connection was closed, but it may also mean an empty packet was
|
49
|
+
# received, as the underlying API makes it impossible to distinguish these two
|
50
|
+
# cases.
|
49
51
|
#
|
50
52
|
# ### Parameters
|
51
53
|
# * `maxlen` - the number of bytes to receive from the socket
|