rbs 3.7.0 → 3.8.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +3 -3
  3. data/.github/workflows/ruby.yml +7 -7
  4. data/CHANGELOG.md +52 -0
  5. data/core/array.rbs +1743 -1580
  6. data/core/basic_object.rbs +38 -35
  7. data/core/comparable.rbs +1 -1
  8. data/core/complex.rbs +165 -93
  9. data/core/data.rbs +1 -1
  10. data/core/dir.rbs +1 -17
  11. data/core/encoding.rbs +12 -6
  12. data/core/enumerable.rbs +270 -266
  13. data/core/enumerator.rbs +0 -2
  14. data/core/env.rbs +1 -1
  15. data/core/errno.rbs +33 -16
  16. data/core/errors.rbs +2 -2
  17. data/core/exception.rbs +236 -170
  18. data/core/fiber.rbs +3 -2
  19. data/core/file.rbs +32 -74
  20. data/core/float.rbs +125 -72
  21. data/core/gc.rbs +138 -40
  22. data/core/hash.rbs +120 -141
  23. data/core/integer.rbs +79 -50
  24. data/core/io/buffer.rbs +49 -43
  25. data/core/io.rbs +97 -144
  26. data/core/kernel.rbs +290 -200
  27. data/core/match_data.rbs +76 -2
  28. data/core/math.rbs +0 -36
  29. data/core/module.rbs +28 -23
  30. data/core/nil_class.rbs +0 -3
  31. data/core/numeric.rbs +100 -103
  32. data/core/object.rbs +0 -4
  33. data/core/object_space/weak_key_map.rbs +3 -4
  34. data/core/object_space.rbs +3 -3
  35. data/core/proc.rbs +0 -2
  36. data/core/process.rbs +109 -57
  37. data/core/ractor.rbs +37 -4
  38. data/core/range.rbs +114 -87
  39. data/core/rational.rbs +0 -2
  40. data/core/rbs/unnamed/argf.rbs +234 -33
  41. data/core/rbs/unnamed/env_class.rbs +35 -53
  42. data/core/rbs/unnamed/random.rbs +1 -2
  43. data/core/regexp.rbs +4 -52
  44. data/core/ruby_vm.rbs +88 -9
  45. data/core/rubygems/config_file.rbs +3 -0
  46. data/core/rubygems/errors.rbs +0 -5
  47. data/core/rubygems/platform.rbs +0 -9
  48. data/core/rubygems/rubygems.rbs +0 -5
  49. data/core/rubygems/version.rbs +6 -6
  50. data/core/set.rbs +3 -15
  51. data/core/string.rbs +130 -136
  52. data/core/struct.rbs +6 -18
  53. data/core/symbol.rbs +14 -21
  54. data/core/thread.rbs +32 -35
  55. data/core/time.rbs +127 -50
  56. data/core/trace_point.rbs +16 -0
  57. data/core/true_class.rbs +0 -1
  58. data/core/warning.rbs +9 -2
  59. data/docs/architecture.md +1 -1
  60. data/docs/syntax.md +1 -1
  61. data/ext/rbs_extension/location.c +29 -19
  62. data/ext/rbs_extension/parser.c +267 -292
  63. data/ext/rbs_extension/parserstate.c +56 -22
  64. data/lib/rbs/annotate/annotations.rb +3 -3
  65. data/lib/rbs/annotate/rdoc_source.rb +2 -2
  66. data/lib/rbs/cli/diff.rb +3 -3
  67. data/lib/rbs/cli/validate.rb +1 -1
  68. data/lib/rbs/cli.rb +13 -13
  69. data/lib/rbs/collection/config.rb +3 -1
  70. data/lib/rbs/definition_builder/ancestor_builder.rb +3 -3
  71. data/lib/rbs/environment_loader.rb +1 -1
  72. data/lib/rbs/namespace.rb +1 -0
  73. data/lib/rbs/parser_aux.rb +2 -2
  74. data/lib/rbs/prototype/rb.rb +11 -8
  75. data/lib/rbs/prototype/rbi.rb +9 -5
  76. data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
  77. data/lib/rbs/prototype/runtime.rb +4 -5
  78. data/lib/rbs/type_name.rb +14 -9
  79. data/lib/rbs/unit_test/type_assertions.rb +2 -2
  80. data/lib/rbs/validator.rb +3 -1
  81. data/lib/rbs/version.rb +1 -1
  82. data/lib/rdoc_plugin/parser.rb +2 -2
  83. data/rbs.gemspec +4 -0
  84. data/sig/ancestor_graph.rbs +4 -4
  85. data/sig/namespace.rbs +2 -3
  86. data/sig/resolver/constant_resolver.rbs +2 -2
  87. data/sig/resolver/context.rbs +1 -1
  88. data/sig/type_alias_regularity.rbs +5 -5
  89. data/sig/typename.rbs +8 -5
  90. data/sig/use_map.rbs +1 -1
  91. data/sig/validator.rbs +2 -2
  92. data/stdlib/base64/0/base64.rbs +0 -9
  93. data/stdlib/benchmark/0/benchmark.rbs +11 -2
  94. data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
  95. data/stdlib/cgi/0/core.rbs +47 -0
  96. data/stdlib/coverage/0/coverage.rbs +0 -3
  97. data/stdlib/csv/0/csv.rbs +18 -58
  98. data/stdlib/date/0/date.rbs +4 -19
  99. data/stdlib/did_you_mean/0/did_you_mean.rbs +0 -5
  100. data/stdlib/digest/0/digest.rbs +25 -2
  101. data/stdlib/erb/0/erb.rbs +0 -1
  102. data/stdlib/etc/0/etc.rbs +51 -34
  103. data/stdlib/fileutils/0/fileutils.rbs +3 -44
  104. data/stdlib/io-console/0/io-console.rbs +69 -15
  105. data/stdlib/ipaddr/0/ipaddr.rbs +8 -4
  106. data/stdlib/json/0/json.rbs +56 -71
  107. data/stdlib/logger/0/log_device.rbs +1 -1
  108. data/stdlib/logger/0/logger.rbs +3 -18
  109. data/stdlib/net-http/0/net-http.rbs +19 -77
  110. data/stdlib/nkf/0/nkf.rbs +30 -0
  111. data/stdlib/objspace/0/objspace.rbs +1 -2
  112. data/stdlib/observable/0/observable.rbs +1 -1
  113. data/stdlib/open-uri/0/open-uri.rbs +52 -0
  114. data/stdlib/open3/0/open3.rbs +0 -8
  115. data/stdlib/openssl/0/openssl.rbs +136 -69
  116. data/stdlib/optparse/0/optparse.rbs +58 -18
  117. data/stdlib/pathname/0/pathname.rbs +2 -8
  118. data/stdlib/pp/0/pp.rbs +3 -1
  119. data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
  120. data/stdlib/pstore/0/pstore.rbs +0 -6
  121. data/stdlib/psych/0/psych.rbs +15 -4
  122. data/stdlib/pty/0/pty.rbs +46 -4
  123. data/stdlib/rdoc/0/code_object.rbs +0 -4
  124. data/stdlib/rdoc/0/markup.rbs +10 -12
  125. data/stdlib/rdoc/0/rdoc.rbs +1 -2
  126. data/stdlib/resolv/0/resolv.rbs +8 -3
  127. data/stdlib/ripper/0/ripper.rbs +0 -2
  128. data/stdlib/securerandom/0/securerandom.rbs +0 -2
  129. data/stdlib/shellwords/0/shellwords.rbs +11 -12
  130. data/stdlib/singleton/0/singleton.rbs +0 -1
  131. data/stdlib/socket/0/addrinfo.rbs +0 -1
  132. data/stdlib/socket/0/basic_socket.rbs +0 -5
  133. data/stdlib/socket/0/socket.rbs +49 -25
  134. data/stdlib/socket/0/tcp_server.rbs +0 -3
  135. data/stdlib/socket/0/tcp_socket.rbs +58 -3
  136. data/stdlib/socket/0/udp_socket.rbs +0 -1
  137. data/stdlib/socket/0/unix_server.rbs +0 -3
  138. data/stdlib/strscan/0/string_scanner.rbs +1265 -422
  139. data/stdlib/tempfile/0/tempfile.rbs +135 -28
  140. data/stdlib/time/0/time.rbs +48 -35
  141. data/stdlib/timeout/0/timeout.rbs +11 -8
  142. data/stdlib/tmpdir/0/tmpdir.rbs +8 -1
  143. data/stdlib/tsort/0/tsort.rbs +0 -4
  144. data/stdlib/uri/0/common.rbs +11 -30
  145. data/stdlib/uri/0/ftp.rbs +1 -1
  146. data/stdlib/uri/0/generic.rbs +22 -18
  147. data/stdlib/uri/0/http.rbs +2 -2
  148. data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
  149. data/stdlib/zlib/0/buf_error.rbs +1 -70
  150. data/stdlib/zlib/0/data_error.rbs +1 -70
  151. data/stdlib/zlib/0/deflate.rbs +8 -72
  152. data/stdlib/zlib/0/error.rbs +1 -70
  153. data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
  154. data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
  155. data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
  156. data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
  157. data/stdlib/zlib/0/gzip_file.rbs +1 -71
  158. data/stdlib/zlib/0/gzip_reader.rbs +3 -74
  159. data/stdlib/zlib/0/gzip_writer.rbs +1 -70
  160. data/stdlib/zlib/0/inflate.rbs +4 -71
  161. data/stdlib/zlib/0/mem_error.rbs +1 -70
  162. data/stdlib/zlib/0/need_dict.rbs +1 -70
  163. data/stdlib/zlib/0/stream_end.rbs +1 -70
  164. data/stdlib/zlib/0/stream_error.rbs +1 -70
  165. data/stdlib/zlib/0/version_error.rbs +1 -70
  166. data/stdlib/zlib/0/zlib.rbs +0 -2
  167. data/stdlib/zlib/0/zstream.rbs +4 -72
  168. metadata +4 -6
@@ -1,49 +1,44 @@
1
1
  # <!-- rdoc-file=object.c -->
2
- # BasicObject is the parent class of all classes in Ruby. It's an explicit
3
- # blank class.
2
+ # `BasicObject` is the parent class of all classes in Ruby. In particular,
3
+ # `BasicObject` is the parent class of class Object, which is itself the default
4
+ # parent class of every Ruby class:
4
5
  #
5
- # BasicObject can be used for creating object hierarchies independent of Ruby's
6
- # object hierarchy, proxy objects like the Delegator class, or other uses where
7
- # namespace pollution from Ruby's methods and classes must be avoided.
6
+ # class Foo; end
7
+ # Foo.superclass # => Object
8
+ # Object.superclass # => BasicObject
8
9
  #
9
- # To avoid polluting BasicObject for other users an appropriately named subclass
10
- # of BasicObject should be created instead of directly modifying BasicObject:
10
+ # `BasicObject` is the only class that has no parent:
11
11
  #
12
- # class MyObjectSystem < BasicObject
13
- # end
12
+ # BasicObject.superclass # => nil
14
13
  #
15
- # BasicObject does not include Kernel (for methods like `puts`) and BasicObject
16
- # is outside of the namespace of the standard library so common classes will not
17
- # be found without using a full class path.
14
+ # Class `BasicObject` can be used to create an object hierarchy (e.g., class
15
+ # Delegator) that is independent of Ruby's object hierarchy. Such objects:
18
16
  #
19
- # A variety of strategies can be used to provide useful portions of the standard
20
- # library to subclasses of BasicObject. A subclass could `include Kernel` to
21
- # obtain `puts`, `exit`, etc. A custom Kernel-like module could be created and
22
- # included or delegation can be used via #method_missing:
17
+ # * Do not have namespace "pollution" from the many methods provided in class
18
+ # Object and its included module Kernel.
19
+ # * Do not have definitions of common classes, and so references to such
20
+ # common classes must be fully qualified (`::String`, not `String`).
23
21
  #
24
- # class MyObjectSystem < BasicObject
25
- # DELEGATE = [:puts, :p]
22
+ # A variety of strategies can be used to provide useful portions of the Standard
23
+ # Library in subclasses of `BasicObject`:
26
24
  #
27
- # def method_missing(name, *args, &block)
28
- # return super unless DELEGATE.include? name
29
- # ::Kernel.send(name, *args, &block)
30
- # end
25
+ # * The immediate subclass could `include Kernel`, which would define methods
26
+ # such as `puts`, `exit`, etc.
27
+ # * A custom Kernel-like module could be created and included.
28
+ # * Delegation can be used via #method_missing:
31
29
  #
32
- # def respond_to_missing?(name, include_private = false)
33
- # DELEGATE.include?(name) or super
34
- # end
35
- # end
30
+ # class MyObjectSystem < BasicObject
31
+ # DELEGATE = [:puts, :p]
36
32
  #
37
- # Access to classes and modules from the Ruby standard library can be obtained
38
- # in a BasicObject subclass by referencing the desired constant from the root
39
- # like `::File` or `::Enumerator`. Like #method_missing, #const_missing can be
40
- # used to delegate constant lookup to `Object`:
33
+ # def method_missing(name, *args, &block)
34
+ # return super unless DELEGATE.include? name
35
+ # ::Kernel.send(name, *args, &block)
36
+ # end
41
37
  #
42
- # class MyObjectSystem < BasicObject
43
- # def self.const_missing(name)
44
- # ::Object.const_get(name)
45
- # end
46
- # end
38
+ # def respond_to_missing?(name, include_private = false)
39
+ # DELEGATE.include?(name)
40
+ # end
41
+ # end
47
42
  #
48
43
  # ### What's Here
49
44
  #
@@ -60,6 +55,14 @@
60
55
  # `self`.
61
56
  # * #instance_exec: Executes the given block in the context of `self`, passing
62
57
  # the given arguments.
58
+ # * #method_missing: Called when `self` is called with a method it does not
59
+ # define.
60
+ # * #singleton_method_added: Called when a singleton method is added to
61
+ # `self`.
62
+ # * #singleton_method_removed: Called when a singleton method is removed from
63
+ # `self`.
64
+ # * #singleton_method_undefined: Called when a singleton method is undefined
65
+ # in `self`.
63
66
  #
64
67
  class BasicObject
65
68
  # <!--
data/core/comparable.rbs CHANGED
@@ -38,7 +38,7 @@
38
38
  #
39
39
  # ## What's Here
40
40
  #
41
- # Module Comparable provides these methods, all of which use method `<=>`:
41
+ # Module Comparable provides these methods, all of which use method `#<=>`:
42
42
  #
43
43
  # * #<: Returns whether `self` is less than the given object.
44
44
  # * #<=: Returns whether `self` is less than or equal to the given object.
data/core/complex.rbs CHANGED
@@ -6,7 +6,8 @@
6
6
  #
7
7
  # The rectangular coordinates of a complex number are called the *real* and
8
8
  # *imaginary* parts; see [Complex number
9
- # definition](https://en.wikipedia.org/wiki/Complex_number#Definition).
9
+ # definition](https://en.wikipedia.org/wiki/Complex_number#Definition_and_basic_
10
+ # operations).
10
11
  #
11
12
  # You can create a Complex object from rectangular coordinates with:
12
13
  #
@@ -16,25 +17,22 @@
16
17
  # string arguments.
17
18
  # * Method String#to_c, for certain strings.
18
19
  #
19
- #
20
20
  # Note that each of the stored parts may be a an instance one of the classes
21
21
  # Complex, Float, Integer, or Rational; they may be retrieved:
22
22
  #
23
23
  # * Separately, with methods Complex#real and Complex#imaginary.
24
24
  # * Together, with method Complex#rect.
25
25
  #
26
- #
27
26
  # The corresponding (computed) polar values may be retrieved:
28
27
  #
29
28
  # * Separately, with methods Complex#abs and Complex#arg.
30
29
  # * Together, with method Complex#polar.
31
30
  #
32
- #
33
31
  # ## Polar Coordinates
34
32
  #
35
33
  # The polar coordinates of a complex number are called the *absolute* and
36
34
  # *argument* parts; see [Complex polar
37
- # plane](https://en.wikipedia.org/wiki/Complex_number#Polar_complex_plane).
35
+ # plane](https://en.wikipedia.org/wiki/Complex_number#Polar_form).
38
36
  #
39
37
  # In this class, the argument part in expressed
40
38
  # [radians](https://en.wikipedia.org/wiki/Radian) (not
@@ -46,19 +44,94 @@
46
44
  # * Method Kernel#Complex, with certain string arguments.
47
45
  # * Method String#to_c, for certain strings.
48
46
  #
49
- #
50
47
  # Note that each of the stored parts may be a an instance one of the classes
51
48
  # Complex, Float, Integer, or Rational; they may be retrieved:
52
49
  #
53
50
  # * Separately, with methods Complex#abs and Complex#arg.
54
51
  # * Together, with method Complex#polar.
55
52
  #
56
- #
57
53
  # The corresponding (computed) rectangular values may be retrieved:
58
54
  #
59
55
  # * Separately, with methods Complex#real and Complex#imag.
60
56
  # * Together, with method Complex#rect.
61
57
  #
58
+ # ## What's Here
59
+ #
60
+ # First, what's elsewhere:
61
+ #
62
+ # * Class Complex inherits (directly or indirectly) from classes
63
+ # [Numeric](rdoc-ref:Numeric@What-27s+Here) and
64
+ # [Object](rdoc-ref:Object@What-27s+Here).
65
+ # * Includes (indirectly) module
66
+ # [Comparable](rdoc-ref:Comparable@What-27s+Here).
67
+ #
68
+ # Here, class Complex has methods for:
69
+ #
70
+ # ### Creating Complex Objects
71
+ #
72
+ # * ::polar: Returns a new Complex object based on given polar coordinates.
73
+ # * ::rect (and its alias ::rectangular): Returns a new Complex object based
74
+ # on given rectangular coordinates.
75
+ #
76
+ # ### Querying
77
+ #
78
+ # * #abs (and its alias #magnitude): Returns the absolute value for `self`.
79
+ # * #arg (and its aliases #angle and #phase): Returns the argument (angle) for
80
+ # `self` in radians.
81
+ # * #denominator: Returns the denominator of `self`.
82
+ # * #finite?: Returns whether both `self.real` and `self.image` are finite.
83
+ # * #hash: Returns the integer hash value for `self`.
84
+ # * #imag (and its alias #imaginary): Returns the imaginary value for `self`.
85
+ # * #infinite?: Returns whether `self.real` or `self.image` is infinite.
86
+ # * #numerator: Returns the numerator of `self`.
87
+ # * #polar: Returns the array `[self.abs, self.arg]`.
88
+ # * #inspect: Returns a string representation of `self`.
89
+ # * #real: Returns the real value for `self`.
90
+ # * #real?: Returns `false`; for compatibility with Numeric#real?.
91
+ # * #rect (and its alias #rectangular): Returns the array `[self.real,
92
+ # self.imag]`.
93
+ #
94
+ # ### Comparing
95
+ #
96
+ # * #<=>: Returns whether `self` is less than, equal to, or greater than the
97
+ # given argument.
98
+ # * #==: Returns whether `self` is equal to the given argument.
99
+ #
100
+ # ### Converting
101
+ #
102
+ # * #rationalize: Returns a Rational object whose value is exactly or
103
+ # approximately equivalent to that of `self.real`.
104
+ # * #to_c: Returns `self`.
105
+ # * #to_d: Returns the value as a BigDecimal object.
106
+ # * #to_f: Returns the value of `self.real` as a Float, if possible.
107
+ # * #to_i: Returns the value of `self.real` as an Integer, if possible.
108
+ # * #to_r: Returns the value of `self.real` as a Rational, if possible.
109
+ # * #to_s: Returns a string representation of `self`.
110
+ #
111
+ # ### Performing Complex Arithmetic
112
+ #
113
+ # * #*: Returns the product of `self` and the given numeric.
114
+ # * #**: Returns `self` raised to power of the given numeric.
115
+ # * #+: Returns the sum of `self` and the given numeric.
116
+ # * #-: Returns the difference of `self` and the given numeric.
117
+ # * #-@: Returns the negation of `self`.
118
+ # * #/: Returns the quotient of `self` and the given numeric.
119
+ # * #abs2: Returns square of the absolute value (magnitude) for `self`.
120
+ # * #conj (and its alias #conjugate): Returns the conjugate of `self`.
121
+ # * #fdiv: Returns `Complex.rect(self.real/numeric, self.imag/numeric)`.
122
+ #
123
+ # ### Working with JSON
124
+ #
125
+ # * ::json_create: Returns a new Complex object, deserialized from the given
126
+ # serialized hash.
127
+ # * #as_json: Returns a serialized hash constructed from `self`.
128
+ # * #to_json: Returns a JSON string representing `self`.
129
+ #
130
+ # These methods are provided by the [JSON gem](https://github.com/ruby/json). To
131
+ # make these methods available:
132
+ #
133
+ # require 'json/add/complex'
134
+ #
62
135
  class Complex < Numeric
63
136
  # <!--
64
137
  # rdoc-file=complex.c
@@ -115,11 +188,11 @@ class Complex < Numeric
115
188
  # -->
116
189
  # Returns the product of `self` and `numeric`:
117
190
  #
118
- # Complex(2, 3) * Complex(2, 3) # => (-5+12i)
119
- # Complex(900) * Complex(1) # => (900+0i)
120
- # Complex(-2, 9) * Complex(-9, 2) # => (0-85i)
121
- # Complex(9, 8) * 4 # => (36+32i)
122
- # Complex(20, 9) * 9.8 # => (196.0+88.2i)
191
+ # Complex.rect(2, 3) * Complex.rect(2, 3) # => (-5+12i)
192
+ # Complex.rect(900) * Complex.rect(1) # => (900+0i)
193
+ # Complex.rect(-2, 9) * Complex.rect(-9, 2) # => (0-85i)
194
+ # Complex.rect(9, 8) * 4 # => (36+32i)
195
+ # Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
123
196
  #
124
197
  def *: (Numeric) -> Complex
125
198
 
@@ -129,8 +202,8 @@ class Complex < Numeric
129
202
  # -->
130
203
  # Returns `self` raised to power `numeric`:
131
204
  #
132
- # Complex('i') ** 2 # => (-1+0i)
133
- # Complex(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
205
+ # Complex.rect(0, 1) ** 2 # => (-1+0i)
206
+ # Complex.rect(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
134
207
  #
135
208
  def **: (Numeric) -> Complex
136
209
 
@@ -140,11 +213,11 @@ class Complex < Numeric
140
213
  # -->
141
214
  # Returns the sum of `self` and `numeric`:
142
215
  #
143
- # Complex(2, 3) + Complex(2, 3) # => (4+6i)
144
- # Complex(900) + Complex(1) # => (901+0i)
145
- # Complex(-2, 9) + Complex(-9, 2) # => (-11+11i)
146
- # Complex(9, 8) + 4 # => (13+8i)
147
- # Complex(20, 9) + 9.8 # => (29.8+9i)
216
+ # Complex.rect(2, 3) + Complex.rect(2, 3) # => (4+6i)
217
+ # Complex.rect(900) + Complex.rect(1) # => (901+0i)
218
+ # Complex.rect(-2, 9) + Complex.rect(-9, 2) # => (-11+11i)
219
+ # Complex.rect(9, 8) + 4 # => (13+8i)
220
+ # Complex.rect(20, 9) + 9.8 # => (29.8+9i)
148
221
  #
149
222
  def +: (Numeric) -> Complex
150
223
 
@@ -156,11 +229,11 @@ class Complex < Numeric
156
229
  # -->
157
230
  # Returns the difference of `self` and `numeric`:
158
231
  #
159
- # Complex(2, 3) - Complex(2, 3) # => (0+0i)
160
- # Complex(900) - Complex(1) # => (899+0i)
161
- # Complex(-2, 9) - Complex(-9, 2) # => (7+7i)
162
- # Complex(9, 8) - 4 # => (5+8i)
163
- # Complex(20, 9) - 9.8 # => (10.2+9i)
232
+ # Complex.rect(2, 3) - Complex.rect(2, 3) # => (0+0i)
233
+ # Complex.rect(900) - Complex.rect(1) # => (899+0i)
234
+ # Complex.rect(-2, 9) - Complex.rect(-9, 2) # => (7+7i)
235
+ # Complex.rect(9, 8) - 4 # => (5+8i)
236
+ # Complex.rect(20, 9) - 9.8 # => (10.2+9i)
164
237
  #
165
238
  def -: (Numeric) -> Complex
166
239
 
@@ -170,8 +243,8 @@ class Complex < Numeric
170
243
  # -->
171
244
  # Returns the negation of `self`, which is the negation of each of its parts:
172
245
  #
173
- # -Complex(1, 2) # => (-1-2i)
174
- # -Complex(-1, -2) # => (1+2i)
246
+ # -Complex.rect(1, 2) # => (-1-2i)
247
+ # -Complex.rect(-1, -2) # => (1+2i)
175
248
  #
176
249
  def -@: () -> Complex
177
250
 
@@ -181,11 +254,11 @@ class Complex < Numeric
181
254
  # -->
182
255
  # Returns the quotient of `self` and `numeric`:
183
256
  #
184
- # Complex(2, 3) / Complex(2, 3) # => ((1/1)+(0/1)*i)
185
- # Complex(900) / Complex(1) # => ((900/1)+(0/1)*i)
186
- # Complex(-2, 9) / Complex(-9, 2) # => ((36/85)-(77/85)*i)
187
- # Complex(9, 8) / 4 # => ((9/4)+(2/1)*i)
188
- # Complex(20, 9) / 9.8 # => (2.0408163265306123+0.9183673469387754i)
257
+ # Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
258
+ # Complex.rect(900) / Complex.rect(1) # => (900+0i)
259
+ # Complex.rect(-2, 9) / Complex.rect(-9, 2) # => ((36/85)-(77/85)*i)
260
+ # Complex.rect(9, 8) / 4 # => ((9/4)+2i)
261
+ # Complex.rect(20, 9) / 9.8 # => (2.0408163265306123+0.9183673469387754i)
189
262
  #
190
263
  def /: (Numeric) -> Complex
191
264
 
@@ -205,18 +278,16 @@ class Complex < Numeric
205
278
  # * `object.imag == 0`. # Always true if object is numeric but not
206
279
  # complex.
207
280
  #
208
- #
209
281
  # * `nil` otherwise.
210
282
  #
211
- #
212
283
  # Examples:
213
284
  #
214
- # Complex(2) <=> 3 # => -1
215
- # Complex(2) <=> 2 # => 0
216
- # Complex(2) <=> 1 # => 1
217
- # Complex(2, 1) <=> 1 # => nil # self.imag not zero.
218
- # Complex(1) <=> Complex(1, 1) # => nil # object.imag not zero.
219
- # Complex(1) <=> 'Foo' # => nil # object.imag not defined.
285
+ # Complex.rect(2) <=> 3 # => -1
286
+ # Complex.rect(2) <=> 2 # => 0
287
+ # Complex.rect(2) <=> 1 # => 1
288
+ # Complex.rect(2, 1) <=> 1 # => nil # self.imag not zero.
289
+ # Complex.rect(1) <=> Complex.rect(1, 1) # => nil # object.imag not zero.
290
+ # Complex.rect(1) <=> 'Foo' # => nil # object.imag not defined.
220
291
  #
221
292
  def <=>: (untyped) -> Integer?
222
293
 
@@ -226,7 +297,7 @@ class Complex < Numeric
226
297
  # -->
227
298
  # Returns `true` if `self.real == object.real` and `self.imag == object.imag`:
228
299
  #
229
- # Complex(2, 3) == Complex(2.0, 3.0) # => true
300
+ # Complex.rect(2, 3) == Complex.rect(2.0, 3.0) # => true
230
301
  #
231
302
  def ==: (untyped) -> bool
232
303
 
@@ -348,9 +419,9 @@ class Complex < Numeric
348
419
  # rdoc-file=complex.c
349
420
  # - fdiv(numeric) -> new_complex
350
421
  # -->
351
- # Returns `Complex(self.real/numeric, self.imag/numeric)`:
422
+ # Returns `Complex.rect(self.real/numeric, self.imag/numeric)`:
352
423
  #
353
- # Complex(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i)
424
+ # Complex.rect(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i)
354
425
  #
355
426
  def fdiv: (Numeric) -> Complex
356
427
 
@@ -361,8 +432,8 @@ class Complex < Numeric
361
432
  # Returns `true` if both `self.real.finite?` and `self.imag.finite?` are true,
362
433
  # `false` otherwise:
363
434
  #
364
- # Complex(1, 1).finite? # => true
365
- # Complex(Float::INFINITY, 0).finite? # => false
435
+ # Complex.rect(1, 1).finite? # => true
436
+ # Complex.rect(Float::INFINITY, 0).finite? # => false
366
437
  #
367
438
  # Related: Numeric#finite?, Float#finite?.
368
439
  #
@@ -379,7 +450,7 @@ class Complex < Numeric
379
450
  # Two Complex objects created from the same values will have the same hash value
380
451
  # (and will compare using #eql?):
381
452
  #
382
- # Complex(1, 2).hash == Complex(1, 2).hash # => true
453
+ # Complex.rect(1, 2).hash == Complex.rect(1, 2).hash # => true
383
454
  #
384
455
  def hash: () -> Integer
385
456
 
@@ -388,8 +459,8 @@ class Complex < Numeric
388
459
  # <!-- rdoc-file=complex.c -->
389
460
  # Returns the imaginary value for `self`:
390
461
  #
391
- # Complex(7).imaginary #=> 0
392
- # Complex(9, -4).imaginary #=> -4
462
+ # Complex.rect(7).imag # => 0
463
+ # Complex.rect(9, -4).imag # => -4
393
464
  #
394
465
  # If `self` was created with [polar
395
466
  # coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is
@@ -405,8 +476,8 @@ class Complex < Numeric
405
476
  # -->
406
477
  # Returns the imaginary value for `self`:
407
478
  #
408
- # Complex(7).imaginary #=> 0
409
- # Complex(9, -4).imaginary #=> -4
479
+ # Complex.rect(7).imag # => 0
480
+ # Complex.rect(9, -4).imag # => -4
410
481
  #
411
482
  # If `self` was created with [polar
412
483
  # coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is
@@ -423,8 +494,8 @@ class Complex < Numeric
423
494
  # Returns `1` if either `self.real.infinite?` or `self.imag.infinite?` is true,
424
495
  # `nil` otherwise:
425
496
  #
426
- # Complex(Float::INFINITY, 0).infinite? # => 1
427
- # Complex(1, 1).infinite? # => nil
497
+ # Complex.rect(Float::INFINITY, 0).infinite? # => 1
498
+ # Complex.rect(1, 1).infinite? # => nil
428
499
  #
429
500
  # Related: Numeric#infinite?, Float#infinite?.
430
501
  #
@@ -436,11 +507,11 @@ class Complex < Numeric
436
507
  # -->
437
508
  # Returns a string representation of `self`:
438
509
  #
439
- # Complex(2).inspect # => "(2+0i)"
440
- # Complex('-8/6').inspect # => "((-4/3)+0i)"
441
- # Complex('1/2i').inspect # => "(0+(1/2)*i)"
442
- # Complex(0, Float::INFINITY).inspect # => "(0+Infinity*i)"
443
- # Complex(Float::NAN, Float::NAN).inspect # => "(NaN+NaN*i)"
510
+ # Complex.rect(2).inspect # => "(2+0i)"
511
+ # Complex.rect(-8, 6).inspect # => "(-8+6i)"
512
+ # Complex.rect(0, Rational(1, 2)).inspect # => "(0+(1/2)*i)"
513
+ # Complex.rect(0, Float::INFINITY).inspect # => "(0+Infinity*i)"
514
+ # Complex.rect(Float::NAN, Float::NAN).inspect # => "(NaN+NaN*i)"
444
515
  #
445
516
  def inspect: () -> String
446
517
 
@@ -475,13 +546,13 @@ class Complex < Numeric
475
546
  # denominator](https://en.wikipedia.org/wiki/Lowest_common_denominator) of the
476
547
  # two:
477
548
  #
478
- # c = Complex(Rational(2, 3), Rational(3, 4)) # => ((2/3)+(3/4)*i)
479
- # c.numerator # => (8+9i)
549
+ # c = Complex.rect(Rational(2, 3), Rational(3, 4)) # => ((2/3)+(3/4)*i)
550
+ # c.numerator # => (8+9i)
480
551
  #
481
552
  # In this example, the lowest common denominator of the two parts is 12; the two
482
553
  # converted parts may be thought of as Rational(8, 12) and Rational(9, 12),
483
554
  # whose numerators, respectively, are 8 and 9; so the returned value of
484
- # `c.numerator` is `Complex(8, 9)`.
555
+ # `c.numerator` is `Complex.rect(8, 9)`.
485
556
  #
486
557
  # Related: Complex#denominator.
487
558
  #
@@ -527,11 +598,11 @@ class Complex < Numeric
527
598
  # -->
528
599
  # Returns the quotient of `self` and `numeric`:
529
600
  #
530
- # Complex(2, 3) / Complex(2, 3) # => ((1/1)+(0/1)*i)
531
- # Complex(900) / Complex(1) # => ((900/1)+(0/1)*i)
532
- # Complex(-2, 9) / Complex(-9, 2) # => ((36/85)-(77/85)*i)
533
- # Complex(9, 8) / 4 # => ((9/4)+(2/1)*i)
534
- # Complex(20, 9) / 9.8 # => (2.0408163265306123+0.9183673469387754i)
601
+ # Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
602
+ # Complex.rect(900) / Complex.rect(1) # => (900+0i)
603
+ # Complex.rect(-2, 9) / Complex.rect(-9, 2) # => ((36/85)-(77/85)*i)
604
+ # Complex.rect(9, 8) / 4 # => ((9/4)+2i)
605
+ # Complex.rect(20, 9) / 9.8 # => (2.0408163265306123+0.9183673469387754i)
535
606
  #
536
607
  def quo: (Numeric) -> Complex
537
608
 
@@ -545,24 +616,24 @@ class Complex < Numeric
545
616
  # With no argument `epsilon` given, returns a Rational object whose value is
546
617
  # exactly equal to that of `self.real.rationalize`:
547
618
  #
548
- # Complex(1, 0).rationalize # => (1/1)
549
- # Complex(1, Rational(0, 1)).rationalize # => (1/1)
550
- # Complex(3.14159, 0).rationalize # => (314159/100000)
619
+ # Complex.rect(1, 0).rationalize # => (1/1)
620
+ # Complex.rect(1, Rational(0, 1)).rationalize # => (1/1)
621
+ # Complex.rect(3.14159, 0).rationalize # => (314159/100000)
551
622
  #
552
623
  # With argument `epsilon` given, returns a Rational object whose value is
553
624
  # exactly or approximately equal to that of `self.real` to the given precision:
554
625
  #
555
- # Complex(3.14159, 0).rationalize(0.1) # => (16/5)
556
- # Complex(3.14159, 0).rationalize(0.01) # => (22/7)
557
- # Complex(3.14159, 0).rationalize(0.001) # => (201/64)
558
- # Complex(3.14159, 0).rationalize(0.0001) # => (333/106)
559
- # Complex(3.14159, 0).rationalize(0.00001) # => (355/113)
560
- # Complex(3.14159, 0).rationalize(0.000001) # => (7433/2366)
561
- # Complex(3.14159, 0).rationalize(0.0000001) # => (9208/2931)
562
- # Complex(3.14159, 0).rationalize(0.00000001) # => (47460/15107)
563
- # Complex(3.14159, 0).rationalize(0.000000001) # => (76149/24239)
564
- # Complex(3.14159, 0).rationalize(0.0000000001) # => (314159/100000)
565
- # Complex(3.14159, 0).rationalize(0.0) # => (3537115888337719/1125899906842624)
626
+ # Complex.rect(3.14159, 0).rationalize(0.1) # => (16/5)
627
+ # Complex.rect(3.14159, 0).rationalize(0.01) # => (22/7)
628
+ # Complex.rect(3.14159, 0).rationalize(0.001) # => (201/64)
629
+ # Complex.rect(3.14159, 0).rationalize(0.0001) # => (333/106)
630
+ # Complex.rect(3.14159, 0).rationalize(0.00001) # => (355/113)
631
+ # Complex.rect(3.14159, 0).rationalize(0.000001) # => (7433/2366)
632
+ # Complex.rect(3.14159, 0).rationalize(0.0000001) # => (9208/2931)
633
+ # Complex.rect(3.14159, 0).rationalize(0.00000001) # => (47460/15107)
634
+ # Complex.rect(3.14159, 0).rationalize(0.000000001) # => (76149/24239)
635
+ # Complex.rect(3.14159, 0).rationalize(0.0000000001) # => (314159/100000)
636
+ # Complex.rect(3.14159, 0).rationalize(0.0) # => (3537115888337719/1125899906842624)
566
637
  #
567
638
  # Related: Complex#to_r.
568
639
  #
@@ -574,8 +645,8 @@ class Complex < Numeric
574
645
  # -->
575
646
  # Returns the real value for `self`:
576
647
  #
577
- # Complex(7).real #=> 7
578
- # Complex(9, -4).real #=> 9
648
+ # Complex.rect(7).real # => 7
649
+ # Complex.rect(9, -4).real # => 9
579
650
  #
580
651
  # If `self` was created with [polar
581
652
  # coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is
@@ -647,8 +718,8 @@ class Complex < Numeric
647
718
  # -->
648
719
  # Returns the value of `self.real` as a Float, if possible:
649
720
  #
650
- # Complex(1, 0).to_f # => 1.0
651
- # Complex(1, Rational(0, 1)).to_f # => 1.0
721
+ # Complex.rect(1, 0).to_f # => 1.0
722
+ # Complex.rect(1, Rational(0, 1)).to_f # => 1.0
652
723
  #
653
724
  # Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or
654
725
  # `Rational(0, *n*)`).
@@ -661,8 +732,8 @@ class Complex < Numeric
661
732
  # -->
662
733
  # Returns the value of `self.real` as an Integer, if possible:
663
734
  #
664
- # Complex(1, 0).to_i # => 1
665
- # Complex(1, Rational(0, 1)).to_i # => 1
735
+ # Complex.rect(1, 0).to_i # => 1
736
+ # Complex.rect(1, Rational(0, 1)).to_i # => 1
666
737
  #
667
738
  # Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or
668
739
  # `Rational(0, *n*)`).
@@ -677,11 +748,12 @@ class Complex < Numeric
677
748
  # -->
678
749
  # Returns the value of `self.real` as a Rational, if possible:
679
750
  #
680
- # Complex(1, 0).to_r # => (1/1)
681
- # Complex(1, Rational(0, 1)).to_r # => (1/1)
751
+ # Complex.rect(1, 0).to_r # => (1/1)
752
+ # Complex.rect(1, Rational(0, 1)).to_r # => (1/1)
753
+ # Complex.rect(1, 0.0).to_r # => (1/1)
682
754
  #
683
755
  # Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or
684
- # `Rational(0, *n*)`).
756
+ # `Rational(0, *n*)`) and `self.imag.to_r` is not exactly zero.
685
757
  #
686
758
  # Related: Complex#rationalize.
687
759
  #
@@ -693,11 +765,11 @@ class Complex < Numeric
693
765
  # -->
694
766
  # Returns a string representation of `self`:
695
767
  #
696
- # Complex(2).to_s # => "2+0i"
697
- # Complex('-8/6').to_s # => "-4/3+0i"
698
- # Complex('1/2i').to_s # => "0+1/2i"
699
- # Complex(0, Float::INFINITY).to_s # => "0+Infinity*i"
700
- # Complex(Float::NAN, Float::NAN).to_s # => "NaN+NaN*i"
768
+ # Complex.rect(2).to_s # => "2+0i"
769
+ # Complex.rect(-8, 6).to_s # => "-8+6i"
770
+ # Complex.rect(0, Rational(1, 2)).to_s # => "0+1/2i"
771
+ # Complex.rect(0, Float::INFINITY).to_s # => "0+Infinity*i"
772
+ # Complex.rect(Float::NAN, Float::NAN).to_s # => "NaN+NaN*i"
701
773
  #
702
774
  def to_s: () -> String
703
775
 
@@ -707,7 +779,7 @@ class Complex < Numeric
707
779
  end
708
780
 
709
781
  # <!-- rdoc-file=complex.c -->
710
- # Equivalent to `Complex(0, 1)`:
782
+ # Equivalent to `Complex.rect(0, 1)`:
711
783
  #
712
784
  # Complex::I # => (0+1i)
713
785
  #
data/core/data.rbs CHANGED
@@ -83,7 +83,7 @@ class Data
83
83
  # #=> #<data Measure amount=1, unit="km">
84
84
  #
85
85
  # Note that member-less Data is acceptable and might be a useful technique for
86
- # defining several homogenous data classes, like
86
+ # defining several homogeneous data classes, like
87
87
  #
88
88
  # class HTTPFetcher
89
89
  # Response = Data.define(:body)