rbs 3.10.0.pre.2 → 3.10.0
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/c-check.yml +1 -1
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/ruby.yml +7 -7
- data/CHANGELOG.md +49 -0
- data/core/array.rbs +56 -3
- data/core/complex.rbs +32 -21
- data/core/encoding.rbs +3 -7
- data/core/enumerable.rbs +1 -1
- data/core/enumerator.rbs +18 -1
- data/core/fiber.rbs +2 -1
- data/core/file.rbs +1 -1
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +208 -21
- data/core/gc.rbs +4 -9
- data/core/hash.rbs +4 -4
- data/core/integer.rbs +78 -38
- data/core/io/buffer.rbs +18 -7
- data/core/io.rbs +8 -8
- data/core/kernel.rbs +8 -8
- data/core/module.rbs +17 -6
- data/core/numeric.rbs +8 -8
- data/core/object_space.rbs +13 -20
- data/core/pathname.rbs +2 -3
- data/core/ractor.rbs +4 -4
- data/core/range.rbs +1 -1
- data/core/rational.rbs +37 -24
- data/core/rbs/unnamed/argf.rbs +1 -1
- data/core/regexp.rbs +3 -3
- data/core/ruby.rbs +53 -0
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +86 -64
- data/core/string.rbs +275 -141
- data/core/thread.rbs +9 -9
- data/core/trace_point.rbs +7 -4
- data/lib/rbs/test/type_check.rb +1 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/json/0/json.rbs +1 -0
- data/stdlib/objspace/0/objspace.rbs +1 -1
- data/stdlib/openssl/0/openssl.rbs +150 -80
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/stringio/0/stringio.rbs +796 -37
- data/stdlib/strscan/0/string_scanner.rbs +1 -1
- data/stdlib/tempfile/0/tempfile.rbs +2 -2
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/uri/0/generic.rbs +1 -1
- metadata +3 -2
data/core/float.rbs
CHANGED
|
@@ -1,15 +1,193 @@
|
|
|
1
|
-
# <!-- rdoc-file=
|
|
2
|
-
# A Float object
|
|
3
|
-
#
|
|
1
|
+
# <!-- rdoc-file=float.rb -->
|
|
2
|
+
# A Float object stores a real number using the native architecture's
|
|
3
|
+
# double-precision floating-point representation.
|
|
4
|
+
#
|
|
5
|
+
# ## Float Imprecisions
|
|
6
|
+
#
|
|
7
|
+
# Some real numbers can be represented precisely as Float objects:
|
|
8
|
+
#
|
|
9
|
+
# 37.5 # => 37.5
|
|
10
|
+
# 98.75 # => 98.75
|
|
11
|
+
# 12.3125 # => 12.3125
|
|
12
|
+
#
|
|
13
|
+
# Others cannot; among these are the transcendental numbers, including:
|
|
14
|
+
#
|
|
15
|
+
# * Pi, *π*: in mathematics, a number of infinite precision:
|
|
16
|
+
# 3.1415926535897932384626433... (to 25 places); in Ruby, it is of limited
|
|
17
|
+
# precision (in this case, to 16 decimal places):
|
|
18
|
+
#
|
|
19
|
+
# Math::PI # => 3.141592653589793
|
|
20
|
+
#
|
|
21
|
+
# * Euler's number, *e*: in mathematics, a number of infinite precision:
|
|
22
|
+
# 2.7182818284590452353602874... (to 25 places); in Ruby, it is of limited
|
|
23
|
+
# precision (in this case, to 15 decimal places):
|
|
24
|
+
#
|
|
25
|
+
# Math::E # => 2.718281828459045
|
|
26
|
+
#
|
|
27
|
+
# Some floating-point computations in Ruby give precise results:
|
|
28
|
+
#
|
|
29
|
+
# 1.0/2 # => 0.5
|
|
30
|
+
# 100.0/8 # => 12.5
|
|
31
|
+
#
|
|
32
|
+
# Others do not:
|
|
33
|
+
#
|
|
34
|
+
# * In mathematics, 2/3 as a decimal number is an infinitely-repeating
|
|
35
|
+
# decimal: 0.666... (forever); in Ruby, `2.0/3` is of limited precision (in
|
|
36
|
+
# this case, to 16 decimal places):
|
|
37
|
+
#
|
|
38
|
+
# 2.0/3 # => 0.6666666666666666
|
|
39
|
+
#
|
|
40
|
+
# * In mathematics, the square root of 2 is an irrational number of infinite
|
|
41
|
+
# precision: 1.4142135623730950488016887... (to 25 decimal places); in Ruby,
|
|
42
|
+
# it is of limited precision (in this case, to 16 decimal places):
|
|
43
|
+
#
|
|
44
|
+
# Math.sqrt(2.0) # => 1.4142135623730951
|
|
45
|
+
#
|
|
46
|
+
# * Even a simple computation can introduce imprecision:
|
|
47
|
+
#
|
|
48
|
+
# x = 0.1 + 0.2 # => 0.30000000000000004
|
|
49
|
+
# y = 0.3 # => 0.3
|
|
50
|
+
# x == y # => false
|
|
51
|
+
#
|
|
52
|
+
# See:
|
|
53
|
+
#
|
|
54
|
+
# * https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
|
|
55
|
+
# * https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#-why-are-rub
|
|
56
|
+
# ys-floats-imprecise
|
|
57
|
+
# * https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
|
|
58
|
+
#
|
|
59
|
+
# Note that precise storage and computation of rational numbers is possible
|
|
60
|
+
# using Rational objects.
|
|
61
|
+
#
|
|
62
|
+
# ## Creating a Float
|
|
63
|
+
#
|
|
64
|
+
# You can create a Float object explicitly with:
|
|
65
|
+
#
|
|
66
|
+
# * A [floating-point literal](rdoc-ref:syntax/literals.rdoc@Float+Literals).
|
|
67
|
+
#
|
|
68
|
+
# You can convert certain objects to Floats with:
|
|
69
|
+
#
|
|
70
|
+
# * Method #Float.
|
|
71
|
+
#
|
|
72
|
+
# ## What's Here
|
|
73
|
+
#
|
|
74
|
+
# First, what's elsewhere. Class Float:
|
|
75
|
+
#
|
|
76
|
+
# * Inherits from [class Numeric](rdoc-ref:Numeric@What-27s+Here) and [class
|
|
77
|
+
# Object](rdoc-ref:Object@What-27s+Here).
|
|
78
|
+
# * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
|
|
79
|
+
#
|
|
80
|
+
# Here, class Float provides methods for:
|
|
81
|
+
#
|
|
82
|
+
# * [Querying](rdoc-ref:Float@Querying)
|
|
83
|
+
# * [Comparing](rdoc-ref:Float@Comparing)
|
|
84
|
+
# * [Converting](rdoc-ref:Float@Converting)
|
|
85
|
+
#
|
|
86
|
+
# ### Querying
|
|
87
|
+
#
|
|
88
|
+
# * #finite?: Returns whether `self` is finite.
|
|
89
|
+
# * #hash: Returns the integer hash code for `self`.
|
|
90
|
+
# * #infinite?: Returns whether `self` is infinite.
|
|
91
|
+
# * #nan?: Returns whether `self` is a NaN (not-a-number).
|
|
92
|
+
#
|
|
93
|
+
# ### Comparing
|
|
4
94
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
95
|
+
# * #<: Returns whether `self` is less than the given value.
|
|
96
|
+
# * #<=: Returns whether `self` is less than or equal to the given value.
|
|
97
|
+
# * #<=>: Returns a number indicating whether `self` is less than, equal to,
|
|
98
|
+
# or greater than the given value.
|
|
99
|
+
# * #== (aliased as #=== and #eql?): Returns whether `self` is equal to the
|
|
100
|
+
# given value.
|
|
101
|
+
# * #>: Returns whether `self` is greater than the given value.
|
|
102
|
+
# * #>=: Returns whether `self` is greater than or equal to the given value.
|
|
103
|
+
#
|
|
104
|
+
# ### Converting
|
|
105
|
+
#
|
|
106
|
+
# * #% (aliased as #modulo): Returns `self` modulo the given value.
|
|
107
|
+
# * #*: Returns the product of `self` and the given value.
|
|
108
|
+
# * #**: Returns the value of `self` raised to the power of the given value.
|
|
109
|
+
# * #+: Returns the sum of `self` and the given value.
|
|
110
|
+
# * #-: Returns the difference of `self` and the given value.
|
|
111
|
+
# * #/: Returns the quotient of `self` and the given value.
|
|
112
|
+
# * #ceil: Returns the smallest number greater than or equal to `self`.
|
|
113
|
+
# * #coerce: Returns a 2-element array containing the given value converted to
|
|
114
|
+
# a Float and `self`
|
|
115
|
+
# * #divmod: Returns a 2-element array containing the quotient and remainder
|
|
116
|
+
# results of dividing `self` by the given value.
|
|
117
|
+
# * #fdiv: Returns the Float result of dividing `self` by the given value.
|
|
118
|
+
# * #floor: Returns the greatest number smaller than or equal to `self`.
|
|
119
|
+
# * #next_float: Returns the next-larger representable Float.
|
|
120
|
+
# * #prev_float: Returns the next-smaller representable Float.
|
|
121
|
+
# * #quo: Returns the quotient from dividing `self` by the given value.
|
|
122
|
+
# * #round: Returns `self` rounded to the nearest value, to a given precision.
|
|
123
|
+
# * #to_i (aliased as #to_int): Returns `self` truncated to an Integer.
|
|
124
|
+
# * #to_s (aliased as #inspect): Returns a string containing the place-value
|
|
125
|
+
# representation of `self` in the given radix.
|
|
126
|
+
# * #truncate: Returns `self` truncated to a given precision.
|
|
127
|
+
#
|
|
128
|
+
# <!-- rdoc-file=float.rb -->
|
|
129
|
+
# A Float object stores a real number using the native architecture's
|
|
130
|
+
# double-precision floating-point representation.
|
|
131
|
+
#
|
|
132
|
+
# ## Float Imprecisions
|
|
133
|
+
#
|
|
134
|
+
# Some real numbers can be represented precisely as Float objects:
|
|
135
|
+
#
|
|
136
|
+
# 37.5 # => 37.5
|
|
137
|
+
# 98.75 # => 98.75
|
|
138
|
+
# 12.3125 # => 12.3125
|
|
139
|
+
#
|
|
140
|
+
# Others cannot; among these are the transcendental numbers, including:
|
|
141
|
+
#
|
|
142
|
+
# * Pi, *π*: in mathematics, a number of infinite precision:
|
|
143
|
+
# 3.1415926535897932384626433... (to 25 places); in Ruby, it is of limited
|
|
144
|
+
# precision (in this case, to 16 decimal places):
|
|
145
|
+
#
|
|
146
|
+
# Math::PI # => 3.141592653589793
|
|
147
|
+
#
|
|
148
|
+
# * Euler's number, *e*: in mathematics, a number of infinite precision:
|
|
149
|
+
# 2.7182818284590452353602874... (to 25 places); in Ruby, it is of limited
|
|
150
|
+
# precision (in this case, to 15 decimal places):
|
|
151
|
+
#
|
|
152
|
+
# Math::E # => 2.718281828459045
|
|
153
|
+
#
|
|
154
|
+
# Some floating-point computations in Ruby give precise results:
|
|
155
|
+
#
|
|
156
|
+
# 1.0/2 # => 0.5
|
|
157
|
+
# 100.0/8 # => 12.5
|
|
158
|
+
#
|
|
159
|
+
# Others do not:
|
|
160
|
+
#
|
|
161
|
+
# * In mathematics, 2/3 as a decimal number is an infinitely-repeating
|
|
162
|
+
# decimal: 0.666... (forever); in Ruby, `2.0/3` is of limited precision (in
|
|
163
|
+
# this case, to 16 decimal places):
|
|
164
|
+
#
|
|
165
|
+
# 2.0/3 # => 0.6666666666666666
|
|
166
|
+
#
|
|
167
|
+
# * In mathematics, the square root of 2 is an irrational number of infinite
|
|
168
|
+
# precision: 1.4142135623730950488016887... (to 25 decimal places); in Ruby,
|
|
169
|
+
# it is of limited precision (in this case, to 16 decimal places):
|
|
170
|
+
#
|
|
171
|
+
# Math.sqrt(2.0) # => 1.4142135623730951
|
|
172
|
+
#
|
|
173
|
+
# * Even a simple computation can introduce imprecision:
|
|
174
|
+
#
|
|
175
|
+
# x = 0.1 + 0.2 # => 0.30000000000000004
|
|
176
|
+
# y = 0.3 # => 0.3
|
|
177
|
+
# x == y # => false
|
|
178
|
+
#
|
|
179
|
+
# See:
|
|
7
180
|
#
|
|
8
181
|
# * https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
|
|
9
182
|
# * https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#-why-are-rub
|
|
10
183
|
# ys-floats-imprecise
|
|
11
184
|
# * https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
|
|
12
185
|
#
|
|
186
|
+
# Note that precise storage and computation of rational numbers is possible
|
|
187
|
+
# using Rational objects.
|
|
188
|
+
#
|
|
189
|
+
# ## Creating a Float
|
|
190
|
+
#
|
|
13
191
|
# You can create a Float object explicitly with:
|
|
14
192
|
#
|
|
15
193
|
# * A [floating-point literal](rdoc-ref:syntax/literals.rdoc@Float+Literals).
|
|
@@ -79,7 +257,7 @@ class Float < Numeric
|
|
|
79
257
|
# rdoc-file=numeric.c
|
|
80
258
|
# - self % other -> float
|
|
81
259
|
# -->
|
|
82
|
-
# Returns `self` modulo `other` as a
|
|
260
|
+
# Returns `self` modulo `other` as a Float.
|
|
83
261
|
#
|
|
84
262
|
# For float `f` and real number `r`, these expressions are equivalent:
|
|
85
263
|
#
|
|
@@ -111,7 +289,7 @@ class Float < Numeric
|
|
|
111
289
|
# rdoc-file=numeric.c
|
|
112
290
|
# - self * other -> numeric
|
|
113
291
|
# -->
|
|
114
|
-
# Returns
|
|
292
|
+
# Returns the numeric product of `self` and `other`:
|
|
115
293
|
#
|
|
116
294
|
# f = 3.14
|
|
117
295
|
# f * 2 # => 6.28
|
|
@@ -124,9 +302,9 @@ class Float < Numeric
|
|
|
124
302
|
|
|
125
303
|
# <!--
|
|
126
304
|
# rdoc-file=numeric.c
|
|
127
|
-
# - self **
|
|
305
|
+
# - self ** exponent -> numeric
|
|
128
306
|
# -->
|
|
129
|
-
#
|
|
307
|
+
# Returns `self` raised to the power `exponent`:
|
|
130
308
|
#
|
|
131
309
|
# f = 3.14
|
|
132
310
|
# f ** 2 # => 9.8596
|
|
@@ -140,15 +318,20 @@ class Float < Numeric
|
|
|
140
318
|
|
|
141
319
|
# <!--
|
|
142
320
|
# rdoc-file=numeric.c
|
|
143
|
-
# - self + other ->
|
|
321
|
+
# - self + other -> float or complex
|
|
144
322
|
# -->
|
|
145
|
-
# Returns
|
|
323
|
+
# Returns the sum of `self` and `other`; the result may be inexact (see Float):
|
|
146
324
|
#
|
|
147
|
-
#
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
151
|
-
#
|
|
325
|
+
# 3.14 + 0 # => 3.14
|
|
326
|
+
# 3.14 + 1 # => 4.140000000000001
|
|
327
|
+
# -3.14 + 0 # => -3.14
|
|
328
|
+
# -3.14 + 1 # => -2.14
|
|
329
|
+
#
|
|
330
|
+
# 3.14 + -3.14 # => 0.0
|
|
331
|
+
# -3.14 + -3.14 # => -6.28
|
|
332
|
+
#
|
|
333
|
+
# 3.14 + Complex(1, 0) # => (4.140000000000001+0i)
|
|
334
|
+
# 3.14 + Rational(1, 1) # => 4.140000000000001
|
|
152
335
|
#
|
|
153
336
|
def +: (Complex) -> Complex
|
|
154
337
|
| (Numeric) -> Float
|
|
@@ -159,7 +342,7 @@ class Float < Numeric
|
|
|
159
342
|
# rdoc-file=numeric.c
|
|
160
343
|
# - self - other -> numeric
|
|
161
344
|
# -->
|
|
162
|
-
# Returns
|
|
345
|
+
# Returns the difference of `self` and `other`:
|
|
163
346
|
#
|
|
164
347
|
# f = 3.14
|
|
165
348
|
# f - 1 # => 2.14
|
|
@@ -172,9 +355,13 @@ class Float < Numeric
|
|
|
172
355
|
|
|
173
356
|
# <!--
|
|
174
357
|
# rdoc-file=numeric.rb
|
|
175
|
-
# - -
|
|
358
|
+
# - -self -> float
|
|
176
359
|
# -->
|
|
177
|
-
# Returns `self`, negated
|
|
360
|
+
# Returns `self`, negated:
|
|
361
|
+
#
|
|
362
|
+
# -3.14 # => -3.14
|
|
363
|
+
# -(-3.14) # => 3.14
|
|
364
|
+
# -0.0 # => -0.0
|
|
178
365
|
#
|
|
179
366
|
def -@: () -> Float
|
|
180
367
|
|
|
@@ -182,7 +369,7 @@ class Float < Numeric
|
|
|
182
369
|
# rdoc-file=numeric.c
|
|
183
370
|
# - self / other -> numeric
|
|
184
371
|
# -->
|
|
185
|
-
# Returns
|
|
372
|
+
# Returns the quotient of `self` and `other`:
|
|
186
373
|
#
|
|
187
374
|
# f = 3.14
|
|
188
375
|
# f / 2 # => 1.57
|
|
@@ -646,7 +833,7 @@ class Float < Numeric
|
|
|
646
833
|
alias magnitude abs
|
|
647
834
|
|
|
648
835
|
# <!-- rdoc-file=numeric.c -->
|
|
649
|
-
# Returns `self` modulo `other` as a
|
|
836
|
+
# Returns `self` modulo `other` as a Float.
|
|
650
837
|
#
|
|
651
838
|
# For float `f` and real number `r`, these expressions are equivalent:
|
|
652
839
|
#
|
data/core/gc.rbs
CHANGED
|
@@ -281,7 +281,7 @@ module GC
|
|
|
281
281
|
# execution both before the method returns and afterward; therefore
|
|
282
282
|
# sweeping may not be completed before the return.
|
|
283
283
|
#
|
|
284
|
-
# Note that these
|
|
284
|
+
# Note that these keyword arguments are implementation- and version-dependent,
|
|
285
285
|
# are not guaranteed to be future-compatible, and may be ignored in some
|
|
286
286
|
# implementations.
|
|
287
287
|
#
|
|
@@ -351,8 +351,9 @@ module GC
|
|
|
351
351
|
# * `:count`: The total number of garbage collections run since application
|
|
352
352
|
# start (count includes both minor and major garbage collections).
|
|
353
353
|
# * `:time`: The total time spent in garbage collections (in milliseconds).
|
|
354
|
-
# * `:heap_allocated_pages`: The total number of
|
|
355
|
-
#
|
|
354
|
+
# * `:heap_allocated_pages`: The total number of allocated pages.
|
|
355
|
+
# * `:heap_empty_pages`: The number of pages with no live objects, and that
|
|
356
|
+
# could be released to the system.
|
|
356
357
|
# * `:heap_sorted_length`: The number of pages that can fit into the buffer
|
|
357
358
|
# that holds references to all pages.
|
|
358
359
|
# * `:heap_allocatable_pages`: The total number of pages the application could
|
|
@@ -367,8 +368,6 @@ module GC
|
|
|
367
368
|
# * `:heap_marked_slots`: The total number of objects marked in the last GC.
|
|
368
369
|
# * `:heap_eden_pages`: The total number of pages which contain at least one
|
|
369
370
|
# live slot.
|
|
370
|
-
# * `:heap_tomb_pages`: The total number of pages which do not contain any
|
|
371
|
-
# live slots.
|
|
372
371
|
# * `:total_allocated_pages`: The cumulative number of pages allocated since
|
|
373
372
|
# application start.
|
|
374
373
|
# * `:total_freed_pages`: The cumulative number of pages freed since
|
|
@@ -582,10 +581,6 @@ module GC
|
|
|
582
581
|
# * `:heap_eden_pages`: The number of pages in the eden heap.
|
|
583
582
|
# * `:heap_eden_slots`: The total number of slots in all of the pages in the
|
|
584
583
|
# eden heap.
|
|
585
|
-
# * `:heap_tomb_pages`: The number of pages in the tomb heap. The tomb heap
|
|
586
|
-
# only contains pages that do not have any live objects.
|
|
587
|
-
# * `:heap_tomb_slots`: The total number of slots in all of the pages in the
|
|
588
|
-
# tomb heap.
|
|
589
584
|
# * `:total_allocated_pages`: The total number of pages that have been
|
|
590
585
|
# allocated in the heap.
|
|
591
586
|
# * `:total_freed_pages`: The total number of pages that have been freed and
|
data/core/hash.rbs
CHANGED
|
@@ -547,7 +547,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
547
547
|
# h < {foo: 0, bar: 1, baz: 2} # => false # Different key.
|
|
548
548
|
# h < {foo: 0, bar: 1, baz: 2} # => false # Different value.
|
|
549
549
|
#
|
|
550
|
-
# See [Hash Inclusion](rdoc-ref:hash_inclusion.rdoc).
|
|
550
|
+
# See [Hash Inclusion](rdoc-ref:language/hash_inclusion.rdoc).
|
|
551
551
|
#
|
|
552
552
|
# Raises TypeError if `other_hash` is not a hash and cannot be converted to a
|
|
553
553
|
# hash.
|
|
@@ -569,7 +569,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
569
569
|
# h0 <= h1 # => true
|
|
570
570
|
# h1 <= h0 # => false
|
|
571
571
|
#
|
|
572
|
-
# See [Hash Inclusion](rdoc-ref:hash_inclusion.rdoc).
|
|
572
|
+
# See [Hash Inclusion](rdoc-ref:language/hash_inclusion.rdoc).
|
|
573
573
|
#
|
|
574
574
|
# Raises TypeError if `other_hash` is not a hash and cannot be converted to a
|
|
575
575
|
# hash.
|
|
@@ -621,7 +621,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
621
621
|
# h > {foo: 0, bar: 1} # => false # Different key.
|
|
622
622
|
# h > {foo: 0, bar: 1} # => false # Different value.
|
|
623
623
|
#
|
|
624
|
-
# See [Hash Inclusion](rdoc-ref:hash_inclusion.rdoc).
|
|
624
|
+
# See [Hash Inclusion](rdoc-ref:language/hash_inclusion.rdoc).
|
|
625
625
|
#
|
|
626
626
|
# Raises TypeError if `other_hash` is not a hash and cannot be converted to a
|
|
627
627
|
# hash.
|
|
@@ -643,7 +643,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
643
643
|
# h0 >= h0 # => true
|
|
644
644
|
# h1 >= h0 # => false
|
|
645
645
|
#
|
|
646
|
-
# See [Hash Inclusion](rdoc-ref:hash_inclusion.rdoc).
|
|
646
|
+
# See [Hash Inclusion](rdoc-ref:language/hash_inclusion.rdoc).
|
|
647
647
|
#
|
|
648
648
|
# Raises TypeError if `other_hash` is not a hash and cannot be converted to a
|
|
649
649
|
# hash.
|
data/core/integer.rbs
CHANGED
|
@@ -146,9 +146,9 @@ class Integer < Numeric
|
|
|
146
146
|
|
|
147
147
|
# <!--
|
|
148
148
|
# rdoc-file=numeric.c
|
|
149
|
-
# - self % other ->
|
|
149
|
+
# - self % other -> real_numeric
|
|
150
150
|
# -->
|
|
151
|
-
# Returns `self` modulo `other` as a real
|
|
151
|
+
# Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
|
|
152
152
|
#
|
|
153
153
|
# For integer `n` and real number `r`, these expressions are equivalent:
|
|
154
154
|
#
|
|
@@ -193,13 +193,13 @@ class Integer < Numeric
|
|
|
193
193
|
|
|
194
194
|
# <!--
|
|
195
195
|
# rdoc-file=numeric.c
|
|
196
|
-
# - self *
|
|
196
|
+
# - self * other -> numeric
|
|
197
197
|
# -->
|
|
198
|
-
#
|
|
198
|
+
# Returns the numeric product of `self` and `other`:
|
|
199
199
|
#
|
|
200
200
|
# 4 * 2 # => 8
|
|
201
|
-
# 4 * -2 # => -8
|
|
202
201
|
# -4 * 2 # => -8
|
|
202
|
+
# 4 * -2 # => -8
|
|
203
203
|
# 4 * 2.0 # => 8.0
|
|
204
204
|
# 4 * Rational(1, 3) # => (4/3)
|
|
205
205
|
# 4 * Complex(2, 0) # => (8+0i)
|
|
@@ -211,17 +211,47 @@ class Integer < Numeric
|
|
|
211
211
|
|
|
212
212
|
# <!--
|
|
213
213
|
# rdoc-file=numeric.c
|
|
214
|
-
# - self **
|
|
214
|
+
# - self ** exponent -> numeric
|
|
215
215
|
# -->
|
|
216
|
-
#
|
|
217
|
-
#
|
|
218
|
-
#
|
|
219
|
-
# 2 **
|
|
220
|
-
#
|
|
221
|
-
#
|
|
222
|
-
# 2 ** 3
|
|
223
|
-
# 2 **
|
|
224
|
-
#
|
|
216
|
+
# Returns `self` raised to the power `exponent`:
|
|
217
|
+
#
|
|
218
|
+
# # Result for non-negative Integer exponent is Integer.
|
|
219
|
+
# 2 ** 0 # => 1
|
|
220
|
+
# 2 ** 1 # => 2
|
|
221
|
+
# 2 ** 2 # => 4
|
|
222
|
+
# 2 ** 3 # => 8
|
|
223
|
+
# -2 ** 3 # => -8
|
|
224
|
+
# # Result for negative Integer exponent is Rational, not Float.
|
|
225
|
+
# 2 ** -3 # => (1/8)
|
|
226
|
+
# -2 ** -3 # => (-1/8)
|
|
227
|
+
#
|
|
228
|
+
# # Result for Float exponent is Float.
|
|
229
|
+
# 2 ** 0.0 # => 1.0
|
|
230
|
+
# 2 ** 1.0 # => 2.0
|
|
231
|
+
# 2 ** 2.0 # => 4.0
|
|
232
|
+
# 2 ** 3.0 # => 8.0
|
|
233
|
+
# -2 ** 3.0 # => -8.0
|
|
234
|
+
# 2 ** -3.0 # => 0.125
|
|
235
|
+
# -2 ** -3.0 # => -0.125
|
|
236
|
+
#
|
|
237
|
+
# # Result for non-negative Complex exponent is Complex with Integer parts.
|
|
238
|
+
# 2 ** Complex(0, 0) # => (1+0i)
|
|
239
|
+
# 2 ** Complex(1, 0) # => (2+0i)
|
|
240
|
+
# 2 ** Complex(2, 0) # => (4+0i)
|
|
241
|
+
# 2 ** Complex(3, 0) # => (8+0i)
|
|
242
|
+
# -2 ** Complex(3, 0) # => (-8+0i)
|
|
243
|
+
# # Result for negative Complex exponent is Complex with Rational parts.
|
|
244
|
+
# 2 ** Complex(-3, 0) # => ((1/8)+(0/1)*i)
|
|
245
|
+
# -2 ** Complex(-3, 0) # => ((-1/8)+(0/1)*i)
|
|
246
|
+
#
|
|
247
|
+
# # Result for Rational exponent is Rational.
|
|
248
|
+
# 2 ** Rational(0, 1) # => (1/1)
|
|
249
|
+
# 2 ** Rational(1, 1) # => (2/1)
|
|
250
|
+
# 2 ** Rational(2, 1) # => (4/1)
|
|
251
|
+
# 2 ** Rational(3, 1) # => (8/1)
|
|
252
|
+
# -2 ** Rational(3, 1) # => (-8/1)
|
|
253
|
+
# 2 ** Rational(-3, 1) # => (1/8)
|
|
254
|
+
# -2 ** Rational(-3, 1) # => (-1/8)
|
|
225
255
|
#
|
|
226
256
|
def **: (Integer) -> Numeric
|
|
227
257
|
| (Float) -> Numeric
|
|
@@ -230,16 +260,20 @@ class Integer < Numeric
|
|
|
230
260
|
|
|
231
261
|
# <!--
|
|
232
262
|
# rdoc-file=numeric.c
|
|
233
|
-
# - self +
|
|
263
|
+
# - self + other -> numeric
|
|
234
264
|
# -->
|
|
235
|
-
#
|
|
265
|
+
# Returns the sum of `self` and `other`:
|
|
266
|
+
#
|
|
267
|
+
# 1 + 1 # => 2
|
|
268
|
+
# 1 + -1 # => 0
|
|
269
|
+
# 1 + 0 # => 1
|
|
270
|
+
# 1 + -2 # => -1
|
|
271
|
+
# 1 + Complex(1, 0) # => (2+0i)
|
|
272
|
+
# 1 + Rational(1, 1) # => (2/1)
|
|
236
273
|
#
|
|
237
|
-
#
|
|
238
|
-
#
|
|
239
|
-
#
|
|
240
|
-
# 2 + 2.0 # => 4.0
|
|
241
|
-
# 2 + Rational(2, 1) # => (4/1)
|
|
242
|
-
# 2 + Complex(2, 0) # => (4+0i)
|
|
274
|
+
# For a computation involving Floats, the result may be inexact (see Float#+):
|
|
275
|
+
#
|
|
276
|
+
# 1 + 3.14 # => 4.140000000000001
|
|
243
277
|
#
|
|
244
278
|
def +: (Integer) -> Integer
|
|
245
279
|
| (Float) -> Float
|
|
@@ -250,9 +284,9 @@ class Integer < Numeric
|
|
|
250
284
|
|
|
251
285
|
# <!--
|
|
252
286
|
# rdoc-file=numeric.c
|
|
253
|
-
# - self -
|
|
287
|
+
# - self - other -> numeric
|
|
254
288
|
# -->
|
|
255
|
-
#
|
|
289
|
+
# Returns the difference of `self` and `other`:
|
|
256
290
|
#
|
|
257
291
|
# 4 - 2 # => 2
|
|
258
292
|
# -4 - 2 # => -6
|
|
@@ -268,28 +302,34 @@ class Integer < Numeric
|
|
|
268
302
|
|
|
269
303
|
# <!--
|
|
270
304
|
# rdoc-file=numeric.rb
|
|
271
|
-
# - -
|
|
305
|
+
# - -self -> integer
|
|
272
306
|
# -->
|
|
273
|
-
# Returns `self`, negated
|
|
307
|
+
# Returns `self`, negated:
|
|
308
|
+
#
|
|
309
|
+
# -1 # => -1
|
|
310
|
+
# -(-1) # => 1
|
|
311
|
+
# -0 # => 0
|
|
274
312
|
#
|
|
275
313
|
def -@: () -> Integer
|
|
276
314
|
|
|
277
315
|
# <!--
|
|
278
316
|
# rdoc-file=numeric.c
|
|
279
|
-
# - self /
|
|
317
|
+
# - self / other -> numeric
|
|
280
318
|
# -->
|
|
281
|
-
#
|
|
319
|
+
# Returns the quotient of `self` and `other`.
|
|
320
|
+
#
|
|
321
|
+
# For integer `other`, truncates the result to an integer:
|
|
282
322
|
#
|
|
283
|
-
#
|
|
284
|
-
#
|
|
285
|
-
#
|
|
286
|
-
#
|
|
323
|
+
# 4 / 3 # => 1
|
|
324
|
+
# 4 / -3 # => -2
|
|
325
|
+
# -4 / 3 # => -2
|
|
326
|
+
# -4 / -3 # => 1
|
|
287
327
|
#
|
|
288
|
-
#
|
|
328
|
+
# For non-integer `other`, returns a non-integer result:
|
|
289
329
|
#
|
|
290
|
-
#
|
|
291
|
-
#
|
|
292
|
-
#
|
|
330
|
+
# 4 / 3.0 # => 1.3333333333333333
|
|
331
|
+
# 4 / Rational(3, 1) # => (4/3)
|
|
332
|
+
# 4 / Complex(3, 0) # => ((4/3)+0i)
|
|
293
333
|
#
|
|
294
334
|
def /: (Integer) -> Integer
|
|
295
335
|
| (Float) -> Float
|
|
@@ -955,7 +995,7 @@ class Integer < Numeric
|
|
|
955
995
|
def magnitude: () -> Integer
|
|
956
996
|
|
|
957
997
|
# <!-- rdoc-file=numeric.c -->
|
|
958
|
-
# Returns `self` modulo `other` as a real
|
|
998
|
+
# Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
|
|
959
999
|
#
|
|
960
1000
|
# For integer `n` and real number `r`, these expressions are equivalent:
|
|
961
1001
|
#
|
data/core/io/buffer.rbs
CHANGED
|
@@ -131,18 +131,25 @@ class IO
|
|
|
131
131
|
# - IO::Buffer.map(file, [size, [offset, [flags]]]) -> io_buffer
|
|
132
132
|
# -->
|
|
133
133
|
# Create an IO::Buffer for reading from `file` by memory-mapping the file.
|
|
134
|
-
# `
|
|
134
|
+
# `file` should be a `File` instance, opened for reading or reading and writing.
|
|
135
135
|
#
|
|
136
|
-
# Optional `size` and `offset` of mapping can be specified.
|
|
136
|
+
# Optional `size` and `offset` of mapping can be specified. Trying to map an
|
|
137
|
+
# empty file or specify `size` of 0 will raise an error. Valid values for
|
|
138
|
+
# `offset` are system-dependent.
|
|
137
139
|
#
|
|
138
|
-
# By default, the buffer
|
|
139
|
-
#
|
|
140
|
-
#
|
|
140
|
+
# By default, the buffer is writable and expects the file to be writable. It is
|
|
141
|
+
# also shared, so several processes can use the same mapping.
|
|
142
|
+
#
|
|
143
|
+
# You can pass IO::Buffer::READONLY in `flags` argument to make a read-only
|
|
144
|
+
# buffer; this allows to work with files opened only for reading. Specifying
|
|
145
|
+
# IO::Buffer::PRIVATE in `flags` creates a private mapping, which will not
|
|
146
|
+
# impact other processes or the underlying file. It also allows updating a
|
|
147
|
+
# buffer created from a read-only file.
|
|
141
148
|
#
|
|
142
149
|
# File.write('test.txt', 'test')
|
|
143
150
|
#
|
|
144
151
|
# buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
|
|
145
|
-
# # => #<IO::Buffer 0x00000001014a0000+4 MAPPED READONLY>
|
|
152
|
+
# # => #<IO::Buffer 0x00000001014a0000+4 EXTERNAL MAPPED FILE SHARED READONLY>
|
|
146
153
|
#
|
|
147
154
|
# buffer.readonly? # => true
|
|
148
155
|
#
|
|
@@ -150,7 +157,7 @@ class IO
|
|
|
150
157
|
# # => "test"
|
|
151
158
|
#
|
|
152
159
|
# buffer.set_string('b', 0)
|
|
153
|
-
# #
|
|
160
|
+
# # 'IO::Buffer#set_string': Buffer is not writable! (IO::Buffer::AccessError)
|
|
154
161
|
#
|
|
155
162
|
# # create read/write mapping: length 4 bytes, offset 0, flags 0
|
|
156
163
|
# buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0)
|
|
@@ -382,6 +389,10 @@ class IO
|
|
|
382
389
|
# * `:U64`: unsigned integer, 8 bytes, big-endian
|
|
383
390
|
# * `:s64`: signed integer, 8 bytes, little-endian
|
|
384
391
|
# * `:S64`: signed integer, 8 bytes, big-endian
|
|
392
|
+
# * `:u128`: unsigned integer, 16 bytes, little-endian
|
|
393
|
+
# * `:U128`: unsigned integer, 16 bytes, big-endian
|
|
394
|
+
# * `:s128`: signed integer, 16 bytes, little-endian
|
|
395
|
+
# * `:S128`: signed integer, 16 bytes, big-endian
|
|
385
396
|
# * `:f32`: float, 4 bytes, little-endian
|
|
386
397
|
# * `:F32`: float, 4 bytes, big-endian
|
|
387
398
|
# * `:f64`: double, 8 bytes, little-endian
|
data/core/io.rbs
CHANGED
|
@@ -1373,7 +1373,7 @@ class IO < Object
|
|
|
1373
1373
|
# Formats and writes `objects` to the stream.
|
|
1374
1374
|
#
|
|
1375
1375
|
# For details on `format_string`, see [Format
|
|
1376
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1376
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1377
1377
|
#
|
|
1378
1378
|
def printf: (String format_string, *untyped objects) -> nil
|
|
1379
1379
|
|
|
@@ -2276,7 +2276,7 @@ class IO < Object
|
|
|
2276
2276
|
#
|
|
2277
2277
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2278
2278
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2279
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2279
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2280
2280
|
#
|
|
2281
2281
|
def self.binread: (String name, ?Integer? length, ?Integer offset) -> String
|
|
2282
2282
|
|
|
@@ -2289,7 +2289,7 @@ class IO < Object
|
|
|
2289
2289
|
#
|
|
2290
2290
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2291
2291
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2292
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2292
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2293
2293
|
#
|
|
2294
2294
|
def self.binwrite: (String name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
|
|
2295
2295
|
|
|
@@ -2354,7 +2354,7 @@ class IO < Object
|
|
|
2354
2354
|
# connected to a new stream `io`.
|
|
2355
2355
|
#
|
|
2356
2356
|
# This method has potential security vulnerabilities if called with untrusted
|
|
2357
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2357
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2358
2358
|
#
|
|
2359
2359
|
# If no block is given, returns the new stream, which depending on given `mode`
|
|
2360
2360
|
# may be open for reading, writing, or both. The stream should be explicitly
|
|
@@ -2529,7 +2529,7 @@ class IO < Object
|
|
|
2529
2529
|
#
|
|
2530
2530
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2531
2531
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2532
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2532
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2533
2533
|
#
|
|
2534
2534
|
# The first argument must be a string that is the path to a file.
|
|
2535
2535
|
#
|
|
@@ -2686,7 +2686,7 @@ class IO < Object
|
|
|
2686
2686
|
#
|
|
2687
2687
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2688
2688
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2689
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2689
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2690
2690
|
#
|
|
2691
2691
|
# The first argument must be a string that is the path to a file.
|
|
2692
2692
|
#
|
|
@@ -2729,7 +2729,7 @@ class IO < Object
|
|
|
2729
2729
|
#
|
|
2730
2730
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2731
2731
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2732
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2732
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2733
2733
|
#
|
|
2734
2734
|
# The first argument must be a string that is the path to a file.
|
|
2735
2735
|
#
|
|
@@ -2954,7 +2954,7 @@ class IO < Object
|
|
|
2954
2954
|
#
|
|
2955
2955
|
# When called from class IO (but not subclasses of IO), this method has
|
|
2956
2956
|
# potential security vulnerabilities if called with untrusted input; see
|
|
2957
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2957
|
+
# [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2958
2958
|
#
|
|
2959
2959
|
# The first argument must be a string that is the path to a file.
|
|
2960
2960
|
#
|