rbs 3.3.2 → 3.4.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +2 -5
- data/.github/workflows/ruby.yml +7 -8
- data/.github/workflows/typecheck.yml +37 -0
- data/CHANGELOG.md +50 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +11 -11
- data/Steepfile +2 -2
- data/core/array.rbs +19 -49
- data/core/basic_object.rbs +2 -2
- data/core/comparable.rbs +17 -8
- data/core/complex.rbs +82 -43
- data/core/data.rbs +2 -4
- data/core/dir.rbs +635 -295
- data/core/enumerable.rbs +11 -18
- data/core/enumerator.rbs +37 -31
- data/core/errors.rbs +4 -0
- data/core/false_class.rbs +34 -15
- data/core/fiber.rbs +23 -0
- data/core/file.rbs +329 -120
- data/core/float.rbs +17 -32
- data/core/gc.rbs +17 -11
- data/core/hash.rbs +22 -44
- data/core/integer.rbs +82 -113
- data/core/io/buffer.rbs +90 -47
- data/core/io.rbs +39 -116
- data/core/kernel.rbs +442 -489
- data/core/match_data.rbs +55 -56
- data/core/module.rbs +45 -1
- data/core/nil_class.rbs +98 -35
- data/core/numeric.rbs +22 -32
- data/core/object_space/weak_key_map.rbs +102 -0
- data/core/process.rbs +1242 -655
- data/core/ractor.rbs +139 -120
- data/core/range.rbs +100 -4
- data/core/rational.rbs +0 -4
- data/core/rbs/unnamed/argf.rbs +16 -8
- data/core/rbs/unnamed/env_class.rbs +0 -24
- data/core/refinement.rbs +8 -0
- data/core/regexp.rbs +1149 -598
- data/core/ruby_vm.rbs +126 -12
- data/core/rubygems/platform.rbs +9 -0
- data/core/rubygems/rubygems.rbs +1 -1
- data/core/rubygems/version.rbs +5 -1
- data/core/set.rbs +20 -22
- data/core/signal.rbs +4 -4
- data/core/string.rbs +283 -230
- data/core/string_io.rbs +2 -14
- data/core/struct.rbs +404 -24
- data/core/symbol.rbs +1 -19
- data/core/thread.rbs +29 -12
- data/core/time.rbs +227 -104
- data/core/trace_point.rbs +2 -5
- data/core/true_class.rbs +54 -21
- data/core/warning.rbs +14 -11
- data/docs/data_and_struct.md +29 -0
- data/docs/syntax.md +3 -5
- data/docs/tools.md +1 -0
- data/ext/rbs_extension/lexer.c +643 -559
- data/ext/rbs_extension/lexer.re +5 -1
- data/ext/rbs_extension/parser.c +12 -3
- data/ext/rbs_extension/unescape.c +7 -47
- data/lib/rbs/cli/diff.rb +4 -1
- data/lib/rbs/cli/validate.rb +280 -0
- data/lib/rbs/cli.rb +2 -194
- data/lib/rbs/collection/config.rb +5 -6
- data/lib/rbs/collection/sources/git.rb +1 -1
- data/lib/rbs/collection.rb +1 -0
- data/lib/rbs/diff.rb +7 -4
- data/lib/rbs/errors.rb +11 -0
- data/lib/rbs/test/errors.rb +4 -1
- data/lib/rbs/test/guaranteed.rb +2 -3
- data/lib/rbs/test/type_check.rb +15 -10
- data/lib/rbs/test.rb +3 -3
- data/lib/rbs/types.rb +29 -0
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +136 -0
- data/lib/rbs/unit_test/type_assertions.rb +341 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/cli/validate.rbs +43 -0
- data/sig/diff.rbs +3 -1
- data/sig/errors.rbs +8 -0
- data/sig/rbs.rbs +1 -1
- data/sig/test/errors.rbs +52 -0
- data/sig/test/guranteed.rbs +9 -0
- data/sig/test/type_check.rbs +19 -0
- data/sig/test.rbs +82 -0
- data/sig/types.rbs +6 -1
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +28 -0
- data/sig/unit_test/type_assertions.rbs +194 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/stdlib/base64/0/base64.rbs +307 -45
- data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
- data/stdlib/coverage/0/coverage.rbs +2 -2
- data/stdlib/csv/0/csv.rbs +25 -55
- data/stdlib/date/0/date.rbs +1 -43
- data/stdlib/date/0/date_time.rbs +1 -13
- data/stdlib/delegate/0/delegator.rbs +186 -0
- data/stdlib/delegate/0/kernel.rbs +47 -0
- data/stdlib/delegate/0/simple_delegator.rbs +98 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
- data/stdlib/erb/0/erb.rbs +2 -2
- data/stdlib/fileutils/0/fileutils.rbs +0 -19
- data/stdlib/io-console/0/io-console.rbs +12 -1
- data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
- data/stdlib/json/0/json.rbs +320 -81
- data/stdlib/logger/0/logger.rbs +9 -5
- data/stdlib/monitor/0/monitor.rbs +78 -0
- data/stdlib/net-http/0/net-http.rbs +1880 -543
- data/stdlib/objspace/0/objspace.rbs +19 -13
- data/stdlib/openssl/0/openssl.rbs +508 -127
- data/stdlib/optparse/0/optparse.rbs +25 -11
- data/stdlib/pathname/0/pathname.rbs +1 -1
- data/stdlib/pp/0/pp.rbs +2 -5
- data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
- data/stdlib/pstore/0/pstore.rbs +2 -4
- data/stdlib/rdoc/0/comment.rbs +1 -2
- data/stdlib/resolv/0/resolv.rbs +4 -2
- data/stdlib/socket/0/socket.rbs +2 -2
- data/stdlib/socket/0/unix_socket.rbs +2 -2
- data/stdlib/strscan/0/string_scanner.rbs +3 -2
- data/stdlib/tempfile/0/tempfile.rbs +1 -1
- data/stdlib/uri/0/common.rbs +245 -123
- metadata +23 -4
- data/lib/rbs/test/spy.rb +0 -6
data/core/complex.rbs
CHANGED
@@ -1,77 +1,107 @@
|
|
1
1
|
# <!-- rdoc-file=complex.c -->
|
2
|
-
# A
|
3
|
-
#
|
4
|
-
# unit. Real a equals complex a+0i mathematically.
|
2
|
+
# A Complex object houses a pair of values, given when the object is created as
|
3
|
+
# either *rectangular coordinates* or *polar coordinates*.
|
5
4
|
#
|
6
|
-
#
|
5
|
+
# ## Rectangular Coordinates
|
7
6
|
#
|
8
|
-
#
|
7
|
+
# The rectangular coordinates of a complex number are called the *real* and
|
8
|
+
# *imaginary* parts; see [Complex number
|
9
|
+
# definition](https://en.wikipedia.org/wiki/Complex_number#Definition).
|
9
10
|
#
|
11
|
+
# You can create a Complex object from rectangular coordinates with:
|
10
12
|
#
|
11
|
-
#
|
13
|
+
# * A [complex literal](rdoc-ref:doc/syntax/literals.rdoc@Complex+Literals).
|
14
|
+
# * Method Complex.rect.
|
15
|
+
# * Method Kernel#Complex, either with numeric arguments or with certain
|
16
|
+
# string arguments.
|
17
|
+
# * Method String#to_c, for certain strings.
|
12
18
|
#
|
13
|
-
# * Method #Complex.
|
14
19
|
#
|
20
|
+
# Note that each of the stored parts may be a an instance one of the classes
|
21
|
+
# Complex, Float, Integer, or Rational; they may be retrieved:
|
15
22
|
#
|
16
|
-
#
|
17
|
-
#
|
23
|
+
# * Separately, with methods Complex#real and Complex#imaginary.
|
24
|
+
# * Together, with method Complex#rect.
|
18
25
|
#
|
19
|
-
# 2+1i #=> (2+1i)
|
20
|
-
# Complex(1) #=> (1+0i)
|
21
|
-
# Complex(2, 3) #=> (2+3i)
|
22
|
-
# Complex.polar(2, 3) #=> (-1.9799849932008908+0.2822400161197344i)
|
23
|
-
# 3.to_c #=> (3+0i)
|
24
26
|
#
|
25
|
-
#
|
27
|
+
# The corresponding (computed) polar values may be retrieved:
|
26
28
|
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# Complex('2/3+3/4i') #=> ((2/3)+(3/4)*i)
|
30
|
-
# Complex('1@2') #=> (-0.4161468365471424+0.9092974268256817i)
|
29
|
+
# * Separately, with methods Complex#abs and Complex#arg.
|
30
|
+
# * Together, with method Complex#polar.
|
31
31
|
#
|
32
|
-
# 0.3.to_c #=> (0.3+0i)
|
33
|
-
# '0.3-0.5i'.to_c #=> (0.3-0.5i)
|
34
|
-
# '2/3+3/4i'.to_c #=> ((2/3)+(3/4)*i)
|
35
|
-
# '1@2'.to_c #=> (-0.4161468365471424+0.9092974268256817i)
|
36
32
|
#
|
37
|
-
#
|
33
|
+
# ## Polar Coordinates
|
38
34
|
#
|
39
|
-
#
|
40
|
-
#
|
35
|
+
# The polar coordinates of a complex number are called the *absolute* and
|
36
|
+
# *argument* parts; see [Complex polar
|
37
|
+
# plane](https://en.wikipedia.org/wiki/Complex_number#Polar_complex_plane).
|
38
|
+
#
|
39
|
+
# You can create a Complex object from polar coordinates with:
|
40
|
+
#
|
41
|
+
# * Method Complex.polar.
|
42
|
+
# * Method Kernel#Complex, with certain string arguments.
|
43
|
+
# * Method String#to_c, for certain strings.
|
44
|
+
#
|
45
|
+
#
|
46
|
+
# Note that each of the stored parts may be a an instance one of the classes
|
47
|
+
# Complex, Float, Integer, or Rational; they may be retrieved:
|
48
|
+
#
|
49
|
+
# * Separately, with methods Complex#abs and Complex#arg.
|
50
|
+
# * Together, with method Complex#polar.
|
51
|
+
#
|
52
|
+
#
|
53
|
+
# The corresponding (computed) rectangular values may be retrieved:
|
54
|
+
#
|
55
|
+
# * Separately, with methods Complex#real and Complex#imag.
|
56
|
+
# * Together, with method Complex#rect.
|
41
57
|
#
|
42
58
|
class Complex < Numeric
|
43
59
|
# <!--
|
44
60
|
# rdoc-file=complex.c
|
45
|
-
# - Complex.polar(abs
|
61
|
+
# - Complex.polar(abs, arg = 0) -> complex
|
46
62
|
# -->
|
47
|
-
# Returns a
|
63
|
+
# Returns a new Complex object formed from the arguments, each of which must be
|
64
|
+
# an instance of Numeric, or an instance of one of its subclasses: Complex,
|
65
|
+
# Float, Integer, Rational; see [Polar
|
66
|
+
# Coordinates](rdoc-ref:Complex@Polar+Coordinates):
|
48
67
|
#
|
49
|
-
# Complex.polar(3
|
50
|
-
# Complex.polar(3,
|
51
|
-
# Complex.polar(3,
|
52
|
-
# Complex.polar(3, -Math::PI/2) #=> (1.836909530733566e-16-3.0i)
|
68
|
+
# Complex.polar(3) # => (3+0i)
|
69
|
+
# Complex.polar(3, 2.0) # => (-1.2484405096414273+2.727892280477045i)
|
70
|
+
# Complex.polar(-3, -2.0) # => (1.2484405096414273+2.727892280477045i)
|
53
71
|
#
|
54
72
|
def self.polar: (Numeric, ?Numeric) -> Complex
|
55
73
|
|
56
74
|
# <!--
|
57
75
|
# rdoc-file=complex.c
|
58
|
-
# - Complex.rect(real
|
59
|
-
# - Complex.rectangular(real[, imag]) -> complex
|
76
|
+
# - Complex.rect(real, imag = 0) -> complex
|
60
77
|
# -->
|
61
|
-
# Returns a
|
78
|
+
# Returns a new Complex object formed from the arguments, each of which must be
|
79
|
+
# an instance of Numeric, or an instance of one of its subclasses: Complex,
|
80
|
+
# Float, Integer, Rational; see [Rectangular
|
81
|
+
# Coordinates](rdoc-ref:Complex@Rectangular+Coordinates):
|
82
|
+
#
|
83
|
+
# Complex.rect(3) # => (3+0i)
|
84
|
+
# Complex.rect(3, Math::PI) # => (3+3.141592653589793i)
|
85
|
+
# Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)
|
62
86
|
#
|
63
|
-
#
|
87
|
+
# Complex.rectangular is an alias for Complex.rect.
|
64
88
|
#
|
65
89
|
def self.rect: (Numeric, ?Numeric) -> Complex
|
66
90
|
|
67
91
|
# <!--
|
68
92
|
# rdoc-file=complex.c
|
69
|
-
# - Complex.rect(real
|
70
|
-
# - Complex.rectangular(real[, imag]) -> complex
|
93
|
+
# - Complex.rect(real, imag = 0) -> complex
|
71
94
|
# -->
|
72
|
-
# Returns a
|
95
|
+
# Returns a new Complex object formed from the arguments, each of which must be
|
96
|
+
# an instance of Numeric, or an instance of one of its subclasses: Complex,
|
97
|
+
# Float, Integer, Rational; see [Rectangular
|
98
|
+
# Coordinates](rdoc-ref:Complex@Rectangular+Coordinates):
|
73
99
|
#
|
74
|
-
# Complex.
|
100
|
+
# Complex.rect(3) # => (3+0i)
|
101
|
+
# Complex.rect(3, Math::PI) # => (3+3.141592653589793i)
|
102
|
+
# Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)
|
103
|
+
#
|
104
|
+
# Complex.rectangular is an alias for Complex.rect.
|
75
105
|
#
|
76
106
|
alias self.rectangular self.rect
|
77
107
|
|
@@ -462,9 +492,16 @@ class Complex < Numeric
|
|
462
492
|
def real?: () -> false
|
463
493
|
|
464
494
|
# <!-- rdoc-file=complex.c -->
|
465
|
-
# Returns a
|
495
|
+
# Returns a new Complex object formed from the arguments, each of which must be
|
496
|
+
# an instance of Numeric, or an instance of one of its subclasses: Complex,
|
497
|
+
# Float, Integer, Rational; see [Rectangular
|
498
|
+
# Coordinates](rdoc-ref:Complex@Rectangular+Coordinates):
|
499
|
+
#
|
500
|
+
# Complex.rect(3) # => (3+0i)
|
501
|
+
# Complex.rect(3, Math::PI) # => (3+3.141592653589793i)
|
502
|
+
# Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)
|
466
503
|
#
|
467
|
-
#
|
504
|
+
# Complex.rectangular is an alias for Complex.rect.
|
468
505
|
#
|
469
506
|
def rect: () -> [ Numeric, Numeric ]
|
470
507
|
|
@@ -559,6 +596,8 @@ class Complex < Numeric
|
|
559
596
|
end
|
560
597
|
|
561
598
|
# <!-- rdoc-file=complex.c -->
|
562
|
-
#
|
599
|
+
# Equivalent to `Complex(0, 1)`:
|
600
|
+
#
|
601
|
+
# Complex::I # => (0+1i)
|
563
602
|
#
|
564
603
|
Complex::I: Complex
|
data/core/data.rbs
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
# distance.unit #=> "km"
|
28
28
|
#
|
29
29
|
# Constructed object also has a reasonable definitions of #== operator, #to_h
|
30
|
-
# hash conversion, and #deconstruct
|
30
|
+
# hash conversion, and #deconstruct / #deconstruct_keys to be used in pattern
|
31
31
|
# matching.
|
32
32
|
#
|
33
33
|
# ::define method accepts an optional block and evaluates it in the context of
|
@@ -66,11 +66,9 @@
|
|
66
66
|
class Data
|
67
67
|
# <!--
|
68
68
|
# rdoc-file=struct.c
|
69
|
-
# - define(name, *symbols) -> class
|
70
69
|
# - define(*symbols) -> class
|
71
70
|
# -->
|
72
|
-
# Defines a new Data class.
|
73
|
-
# stored in `Data::<name>` constant.
|
71
|
+
# Defines a new Data class.
|
74
72
|
#
|
75
73
|
# measure = Data.define(:amount, :unit)
|
76
74
|
# #=> #<Class:0x00007f70c6868498>
|