rbs 4.0.0.dev.5 → 4.0.1.dev.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.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +1 -0
  3. data/.github/workflows/c-check.yml +8 -4
  4. data/.github/workflows/comments.yml +3 -1
  5. data/.github/workflows/dependabot.yml +1 -1
  6. data/.github/workflows/ruby.yml +10 -0
  7. data/.github/workflows/rust.yml +95 -0
  8. data/CHANGELOG.md +323 -0
  9. data/Rakefile +12 -29
  10. data/Steepfile +1 -0
  11. data/config.yml +393 -37
  12. data/core/array.rbs +218 -188
  13. data/core/basic_object.rbs +9 -8
  14. data/core/class.rbs +6 -5
  15. data/core/comparable.rbs +45 -31
  16. data/core/complex.rbs +52 -40
  17. data/core/dir.rbs +57 -45
  18. data/core/encoding.rbs +5 -5
  19. data/core/enumerable.rbs +96 -91
  20. data/core/enumerator.rbs +4 -3
  21. data/core/errno.rbs +3 -2
  22. data/core/errors.rbs +31 -29
  23. data/core/exception.rbs +12 -12
  24. data/core/fiber.rbs +36 -36
  25. data/core/file.rbs +186 -113
  26. data/core/file_test.rbs +2 -2
  27. data/core/float.rbs +41 -32
  28. data/core/gc.rbs +78 -70
  29. data/core/hash.rbs +70 -60
  30. data/core/integer.rbs +32 -28
  31. data/core/io/buffer.rbs +36 -36
  32. data/core/io/wait.rbs +7 -7
  33. data/core/io.rbs +120 -135
  34. data/core/kernel.rbs +189 -139
  35. data/core/marshal.rbs +3 -3
  36. data/core/match_data.rbs +14 -12
  37. data/core/math.rbs +69 -67
  38. data/core/method.rbs +6 -6
  39. data/core/module.rbs +146 -85
  40. data/core/nil_class.rbs +4 -3
  41. data/core/numeric.rbs +35 -32
  42. data/core/object.rbs +6 -8
  43. data/core/object_space.rbs +11 -10
  44. data/core/pathname.rbs +131 -81
  45. data/core/proc.rbs +65 -33
  46. data/core/process.rbs +219 -201
  47. data/core/ractor.rbs +15 -11
  48. data/core/random.rbs +4 -3
  49. data/core/range.rbs +52 -47
  50. data/core/rational.rbs +5 -5
  51. data/core/rbs/unnamed/argf.rbs +58 -51
  52. data/core/rbs/unnamed/env_class.rbs +18 -13
  53. data/core/rbs/unnamed/main_class.rbs +123 -0
  54. data/core/rbs/unnamed/random.rbs +7 -5
  55. data/core/regexp.rbs +236 -197
  56. data/core/ruby.rbs +1 -1
  57. data/core/ruby_vm.rbs +32 -30
  58. data/core/rubygems/config_file.rbs +5 -5
  59. data/core/rubygems/errors.rbs +1 -1
  60. data/core/rubygems/requirement.rbs +5 -5
  61. data/core/rubygems/rubygems.rbs +5 -3
  62. data/core/set.rbs +17 -16
  63. data/core/signal.rbs +2 -2
  64. data/core/string.rbs +311 -292
  65. data/core/struct.rbs +26 -25
  66. data/core/symbol.rbs +25 -24
  67. data/core/thread.rbs +40 -34
  68. data/core/time.rbs +47 -42
  69. data/core/trace_point.rbs +34 -31
  70. data/core/true_class.rbs +2 -2
  71. data/core/unbound_method.rbs +10 -10
  72. data/core/warning.rbs +7 -7
  73. data/docs/collection.md +1 -1
  74. data/docs/config.md +171 -0
  75. data/docs/inline.md +110 -4
  76. data/docs/syntax.md +13 -12
  77. data/ext/rbs_extension/ast_translation.c +489 -135
  78. data/ext/rbs_extension/class_constants.c +8 -0
  79. data/ext/rbs_extension/class_constants.h +4 -0
  80. data/ext/rbs_extension/legacy_location.c +28 -51
  81. data/ext/rbs_extension/legacy_location.h +37 -0
  82. data/ext/rbs_extension/main.c +12 -20
  83. data/include/rbs/ast.h +423 -195
  84. data/include/rbs/lexer.h +2 -2
  85. data/include/rbs/location.h +25 -44
  86. data/include/rbs/parser.h +2 -2
  87. data/include/rbs/util/rbs_constant_pool.h +0 -3
  88. data/include/rbs.h +8 -0
  89. data/lib/rbs/ast/ruby/annotations.rb +157 -4
  90. data/lib/rbs/ast/ruby/members.rb +374 -22
  91. data/lib/rbs/cli/validate.rb +5 -60
  92. data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
  93. data/lib/rbs/definition_builder.rb +60 -27
  94. data/lib/rbs/errors.rb +0 -11
  95. data/lib/rbs/inline_parser.rb +1 -1
  96. data/lib/rbs/parser_aux.rb +20 -7
  97. data/lib/rbs/prototype/helpers.rb +57 -0
  98. data/lib/rbs/prototype/rb.rb +1 -26
  99. data/lib/rbs/prototype/rbi.rb +1 -20
  100. data/lib/rbs/test/type_check.rb +3 -0
  101. data/lib/rbs/types.rb +62 -52
  102. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  103. data/lib/rbs/version.rb +1 -1
  104. data/lib/rbs.rb +0 -1
  105. data/rbs.gemspec +1 -1
  106. data/rust/.gitignore +1 -0
  107. data/rust/Cargo.lock +378 -0
  108. data/rust/Cargo.toml +7 -0
  109. data/rust/ruby-rbs/Cargo.toml +22 -0
  110. data/rust/ruby-rbs/build.rs +764 -0
  111. data/rust/ruby-rbs/examples/locations.rs +60 -0
  112. data/rust/ruby-rbs/src/lib.rs +1 -0
  113. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  114. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  115. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  116. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  117. data/rust/ruby-rbs-sys/build.rs +204 -0
  118. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  119. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  120. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  121. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  122. data/sig/ast/ruby/annotations.rbs +191 -4
  123. data/sig/ast/ruby/members.rbs +21 -1
  124. data/sig/cli/validate.rbs +1 -6
  125. data/sig/definition_builder.rbs +2 -0
  126. data/sig/errors.rbs +0 -8
  127. data/sig/method_types.rbs +1 -1
  128. data/sig/parser.rbs +17 -13
  129. data/sig/prototype/helpers.rbs +2 -0
  130. data/sig/types.rbs +10 -11
  131. data/sig/unit_test/spy.rbs +0 -8
  132. data/sig/unit_test/type_assertions.rbs +11 -0
  133. data/src/ast.c +339 -161
  134. data/src/lexstate.c +1 -1
  135. data/src/location.c +7 -47
  136. data/src/parser.c +674 -480
  137. data/src/util/rbs_constant_pool.c +0 -4
  138. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
  139. data/stdlib/cgi-escape/0/escape.rbs +4 -4
  140. data/stdlib/coverage/0/coverage.rbs +4 -3
  141. data/stdlib/date/0/date.rbs +33 -28
  142. data/stdlib/date/0/date_time.rbs +24 -23
  143. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  144. data/stdlib/erb/0/erb.rbs +64 -53
  145. data/stdlib/etc/0/etc.rbs +55 -50
  146. data/stdlib/fileutils/0/fileutils.rbs +138 -125
  147. data/stdlib/forwardable/0/forwardable.rbs +10 -10
  148. data/stdlib/io-console/0/io-console.rbs +2 -2
  149. data/stdlib/json/0/json.rbs +135 -108
  150. data/stdlib/monitor/0/monitor.rbs +3 -3
  151. data/stdlib/net-http/0/net-http.rbs +159 -134
  152. data/stdlib/objspace/0/objspace.rbs +8 -7
  153. data/stdlib/open-uri/0/open-uri.rbs +8 -8
  154. data/stdlib/open3/0/open3.rbs +36 -35
  155. data/stdlib/openssl/0/openssl.rbs +144 -129
  156. data/stdlib/optparse/0/optparse.rbs +18 -14
  157. data/stdlib/pathname/0/pathname.rbs +2 -2
  158. data/stdlib/pp/0/pp.rbs +9 -8
  159. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  160. data/stdlib/pstore/0/pstore.rbs +35 -30
  161. data/stdlib/psych/0/psych.rbs +61 -8
  162. data/stdlib/psych/0/store.rbs +2 -4
  163. data/stdlib/pty/0/pty.rbs +9 -6
  164. data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
  165. data/stdlib/ripper/0/ripper.rbs +20 -17
  166. data/stdlib/securerandom/0/securerandom.rbs +1 -1
  167. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  168. data/stdlib/socket/0/addrinfo.rbs +7 -7
  169. data/stdlib/socket/0/basic_socket.rbs +3 -3
  170. data/stdlib/socket/0/ip_socket.rbs +10 -8
  171. data/stdlib/socket/0/socket.rbs +10 -9
  172. data/stdlib/socket/0/tcp_server.rbs +1 -1
  173. data/stdlib/socket/0/tcp_socket.rbs +1 -1
  174. data/stdlib/socket/0/udp_socket.rbs +1 -1
  175. data/stdlib/socket/0/unix_server.rbs +1 -1
  176. data/stdlib/stringio/0/stringio.rbs +55 -54
  177. data/stdlib/strscan/0/string_scanner.rbs +46 -44
  178. data/stdlib/tempfile/0/tempfile.rbs +24 -20
  179. data/stdlib/time/0/time.rbs +7 -5
  180. data/stdlib/tsort/0/tsort.rbs +7 -6
  181. data/stdlib/uri/0/common.rbs +26 -18
  182. data/stdlib/uri/0/file.rbs +2 -2
  183. data/stdlib/uri/0/generic.rbs +2 -2
  184. data/stdlib/uri/0/http.rbs +2 -2
  185. data/stdlib/uri/0/ldap.rbs +2 -2
  186. data/stdlib/uri/0/mailto.rbs +3 -3
  187. data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
  188. data/stdlib/zlib/0/deflate.rbs +4 -3
  189. data/stdlib/zlib/0/gzip_reader.rbs +4 -4
  190. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  191. data/stdlib/zlib/0/inflate.rbs +1 -1
  192. data/stdlib/zlib/0/need_dict.rbs +1 -1
  193. metadata +23 -5
  194. data/.github/workflows/valgrind.yml +0 -42
@@ -17,7 +17,8 @@
17
17
  # * Do not have namespace "pollution" from the many methods provided in class
18
18
  # Object and its included module Kernel.
19
19
  # * Do not have definitions of common classes, and so references to such
20
- # common classes must be fully qualified (`::String`, not `String`).
20
+ # common classes must be fully qualified (<code>::String</code>, not
21
+ # `String`).
21
22
  #
22
23
  # A variety of strategies can be used to provide useful portions of the Standard
23
24
  # Library in subclasses of `BasicObject`:
@@ -92,8 +93,8 @@ class BasicObject
92
93
  # classes to provide class-specific meaning.
93
94
  #
94
95
  # Unlike #==, the #equal? method should never be overridden by subclasses as it
95
- # is used to determine object identity (that is, `a.equal?(b)` if and only if
96
- # `a` is the same object as `b`):
96
+ # is used to determine object identity (that is, <code>a.equal?(b)</code> if and
97
+ # only if `a` is the same object as `b`):
97
98
  #
98
99
  # obj = "a"
99
100
  # other = obj.dup
@@ -174,8 +175,8 @@ class BasicObject
174
175
  # classes to provide class-specific meaning.
175
176
  #
176
177
  # Unlike #==, the #equal? method should never be overridden by subclasses as it
177
- # is used to determine object identity (that is, `a.equal?(b)` if and only if
178
- # `a` is the same object as `b`):
178
+ # is used to determine object identity (that is, <code>a.equal?(b)</code> if and
179
+ # only if `a` is the same object as `b`):
179
180
  #
180
181
  # obj = "a"
181
182
  # other = obj.dup
@@ -315,7 +316,7 @@ class BasicObject
315
316
  # def Chatty.three() end
316
317
  # end
317
318
  #
318
- # *produces:*
319
+ # <em>produces:</em>
319
320
  #
320
321
  # Adding singleton_method_added
321
322
  # Adding one
@@ -343,7 +344,7 @@ class BasicObject
343
344
  # end
344
345
  # end
345
346
  #
346
- # *produces:*
347
+ # <em>produces:</em>
347
348
  #
348
349
  # Removing three
349
350
  # Removing one
@@ -367,7 +368,7 @@ class BasicObject
367
368
  # end
368
369
  # end
369
370
  #
370
- # *produces:*
371
+ # <em>produces:</em>
371
372
  #
372
373
  # Undefining one
373
374
  #
data/core/class.rbs CHANGED
@@ -10,8 +10,9 @@
10
10
  # When a new class is created, an object of type Class is initialized and
11
11
  # assigned to a global constant (Name in this case).
12
12
  #
13
- # When `Name.new` is called to create a new object, the #new method in Class is
14
- # run by default. This can be demonstrated by overriding #new in Class:
13
+ # When <code>Name.new</code> is called to create a new object, the #new method
14
+ # in Class is run by default. This can be demonstrated by overriding #new in
15
+ # Class:
15
16
  #
16
17
  # class Class
17
18
  # alias old_new new
@@ -26,7 +27,7 @@
26
27
  #
27
28
  # n = Name.new
28
29
  #
29
- # *produces:*
30
+ # <em>produces:</em>
30
31
  #
31
32
  # Creating a new Name
32
33
  #
@@ -144,7 +145,7 @@ class Class < Module
144
145
  # class Baz < Bar
145
146
  # end
146
147
  #
147
- # *produces:*
148
+ # <em>produces:</em>
148
149
  #
149
150
  # New subclass: Bar
150
151
  # New subclass: Baz
@@ -157,7 +158,7 @@ class Class < Module
157
158
  # -->
158
159
  # Calls #allocate to create a new object of *class*'s class, then invokes that
159
160
  # object's #initialize method, passing it *args*. This is the method that ends
160
- # up getting called whenever an object is constructed using `.new`.
161
+ # up getting called whenever an object is constructed using <code>.new</code>.
161
162
  #
162
163
  def new: () -> untyped
163
164
 
data/core/comparable.rbs CHANGED
@@ -1,12 +1,13 @@
1
1
  # <!-- rdoc-file=compar.c -->
2
2
  # The Comparable mixin is used by classes whose objects may be ordered. The
3
- # class must define the `<=>` operator, which compares the receiver against
4
- # another object, returning a value less than 0, returning 0, or returning a
5
- # value greater than 0, depending on whether the receiver is less than, equal
6
- # to, or greater than the other object. If the other object is not comparable
7
- # then the `<=>` operator should return `nil`. Comparable uses `<=>` to
8
- # implement the conventional comparison operators (`<`, `<=`, `==`, `>=`, and
9
- # `>`) and the method `between?`.
3
+ # class must define the <code><=></code> operator, which compares the receiver
4
+ # against another object, returning a value less than 0, returning 0, or
5
+ # returning a value greater than 0, depending on whether the receiver is less
6
+ # than, equal to, or greater than the other object. If the other object is not
7
+ # comparable then the <code><=></code> operator should return `nil`. Comparable
8
+ # uses <code><=></code> to implement the conventional comparison operators
9
+ # (<code><</code>, <code><=</code>, <code>==</code>, <code>>=</code>, and
10
+ # <code>></code>) and the method <code>between?</code>.
10
11
  #
11
12
  # class StringSorter
12
13
  # include Comparable
@@ -38,7 +39,8 @@
38
39
  #
39
40
  # ## What's Here
40
41
  #
41
- # Module Comparable provides these methods, all of which use method `#<=>`:
42
+ # Module Comparable provides these methods, all of which use method
43
+ # <code>#<=></code>:
42
44
  #
43
45
  # * #<: Returns whether `self` is less than the given object.
44
46
  # * #<=: Returns whether `self` is less than or equal to the given object.
@@ -46,10 +48,11 @@
46
48
  # * #>: Returns whether `self` is greater than the given object.
47
49
  # * #>=: Returns whether `self` is greater than or equal to the given object.
48
50
  # * #between?: Returns `true` if `self` is between two given objects.
49
- # * #clamp: For given objects `min` and `max`, or range `(min..max)`, returns:
51
+ # * #clamp: For given objects `min` and `max`, or range
52
+ # <code>(min..max)</code>, returns:
50
53
  #
51
- # * `min` if `(self <=> min) < 0`.
52
- # * `max` if `(self <=> max) > 0`.
54
+ # * `min` if <code>(self <=> min) < 0</code>.
55
+ # * `max` if <code>(self <=> max) > 0</code>.
53
56
  # * `self` otherwise.
54
57
  #
55
58
  module Comparable : _WithSpaceshipOperator
@@ -57,8 +60,8 @@ module Comparable : _WithSpaceshipOperator
57
60
  # rdoc-file=compar.c
58
61
  # - self < other -> true or false
59
62
  # -->
60
- # Returns whether `self` is "less than" `other`; equivalent to `(self <=> other)
61
- # < 0`:
63
+ # Returns whether `self` is "less than" `other`; equivalent to <code>(self <=>
64
+ # other) < 0</code>:
62
65
  #
63
66
  # 'foo' < 'foo' # => false
64
67
  # 'foo' < 'food' # => true
@@ -70,7 +73,7 @@ module Comparable : _WithSpaceshipOperator
70
73
  # - self <= other -> true or false
71
74
  # -->
72
75
  # Returns whether `self` is "less than or equal to" `other`; equivalent to
73
- # `(self <=> other) <= 0`:
76
+ # <code>(self <=> other) <= 0</code>:
74
77
  #
75
78
  # 'foo' <= 'foo' # => true
76
79
  # 'foo' <= 'food' # => true
@@ -82,8 +85,9 @@ module Comparable : _WithSpaceshipOperator
82
85
  # rdoc-file=compar.c
83
86
  # - obj == other -> true or false
84
87
  # -->
85
- # Compares two objects based on the receiver's `<=>` method, returning true if
86
- # it returns 0. Also returns true if *obj* and *other* are the same object.
88
+ # Compares two objects based on the receiver's <code><=></code> method,
89
+ # returning true if it returns 0. Also returns true if *obj* and *other* are the
90
+ # same object.
87
91
  #
88
92
  def ==: (untyped other) -> bool
89
93
 
@@ -91,8 +95,8 @@ module Comparable : _WithSpaceshipOperator
91
95
  # rdoc-file=compar.c
92
96
  # - obj > other -> true or false
93
97
  # -->
94
- # Compares two objects based on the receiver's `<=>` method, returning true if
95
- # it returns a value greater than 0.
98
+ # Compares two objects based on the receiver's <code><=></code> method,
99
+ # returning true if it returns a value greater than 0.
96
100
  #
97
101
  def >: (untyped other) -> bool
98
102
 
@@ -100,8 +104,8 @@ module Comparable : _WithSpaceshipOperator
100
104
  # rdoc-file=compar.c
101
105
  # - obj >= other -> true or false
102
106
  # -->
103
- # Compares two objects based on the receiver's `<=>` method, returning true if
104
- # it returns a value greater than or equal to 0.
107
+ # Compares two objects based on the receiver's <code><=></code> method,
108
+ # returning true if it returns a value greater than or equal to 0.
105
109
  #
106
110
  def >=: (untyped other) -> bool
107
111
 
@@ -109,8 +113,8 @@ module Comparable : _WithSpaceshipOperator
109
113
  # rdoc-file=compar.c
110
114
  # - obj.between?(min, max) -> true or false
111
115
  # -->
112
- # Returns `false` if *obj* `<=>` *min* is less than zero or if *obj* `<=>` *max*
113
- # is greater than zero, `true` otherwise.
116
+ # Returns `false` if *obj* <code><=></code> *min* is less than zero or if *obj*
117
+ # <code><=></code> *max* is greater than zero, `true` otherwise.
114
118
  #
115
119
  # 3.between?(1, 5) #=> true
116
120
  # 6.between?(1, 5) #=> false
@@ -124,8 +128,9 @@ module Comparable : _WithSpaceshipOperator
124
128
  # - obj.clamp(min, max) -> obj
125
129
  # - obj.clamp(range) -> obj
126
130
  # -->
127
- # In `(min, max)` form, returns *min* if *obj* `<=>` *min* is less than zero,
128
- # *max* if *obj* `<=>` *max* is greater than zero, and *obj* otherwise.
131
+ # In <code>(min, max)</code> form, returns *min* if *obj* <code><=></code> *min*
132
+ # is less than zero, *max* if *obj* <code><=></code> *max* is greater than zero,
133
+ # and *obj* otherwise.
129
134
  #
130
135
  # 12.clamp(0, 100) #=> 12
131
136
  # 523.clamp(0, 100) #=> 100
@@ -140,9 +145,10 @@ module Comparable : _WithSpaceshipOperator
140
145
  # -20.clamp(0, nil) #=> 0
141
146
  # 523.clamp(nil, 100) #=> 100
142
147
  #
143
- # In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less
144
- # than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and
145
- # *obj* otherwise.
148
+ # In <code>(range)</code> form, returns <em>range.begin</em> if *obj*
149
+ # <code><=></code> <em>range.begin</em> is less than zero, <em>range.end</em> if
150
+ # *obj* <code><=></code> <em>range.end</em> is greater than zero, and *obj*
151
+ # otherwise.
146
152
  #
147
153
  # 12.clamp(0..100) #=> 12
148
154
  # 523.clamp(0..100) #=> 100
@@ -151,13 +157,13 @@ module Comparable : _WithSpaceshipOperator
151
157
  # 'd'.clamp('a'..'f') #=> 'd'
152
158
  # 'z'.clamp('a'..'f') #=> 'f'
153
159
  #
154
- # If *range.begin* is `nil`, it is considered smaller than *obj*, and if
155
- # *range.end* is `nil`, it is considered greater than *obj*.
160
+ # If <em>range.begin</em> is `nil`, it is considered smaller than *obj*, and if
161
+ # <em>range.end</em> is `nil`, it is considered greater than *obj*.
156
162
  #
157
163
  # -20.clamp(0..) #=> 0
158
164
  # 523.clamp(..100) #=> 100
159
165
  #
160
- # When *range.end* is excluded and not `nil`, an exception is raised.
166
+ # When <em>range.end</em> is excluded and not `nil`, an exception is raised.
161
167
  #
162
168
  # 100.clamp(0...100) # ArgumentError
163
169
  #
@@ -174,5 +180,13 @@ interface Comparable::_WithSpaceshipOperator
174
180
  # If `other` is less than `self`, it returns a positive Integer.
175
181
  # If no comparison is defined with `other` and `self`, it returns `nil`.
176
182
  #
177
- def <=>: (untyped other) -> Integer?
183
+ def <=>: (untyped other) -> Comparable::_CompareToZero?
184
+ end
185
+
186
+ # This interface indicates a type is comparable against zero.
187
+ #
188
+ interface Comparable::_CompareToZero
189
+ def <: (0) -> boolish
190
+
191
+ def >: (0) -> boolish
178
192
  end
data/core/complex.rbs CHANGED
@@ -79,17 +79,19 @@
79
79
  # * #arg (and its aliases #angle and #phase): Returns the argument (angle) for
80
80
  # `self` in radians.
81
81
  # * #denominator: Returns the denominator of `self`.
82
- # * #finite?: Returns whether both `self.real` and `self.image` are finite.
82
+ # * #finite?: Returns whether both <code>self.real</code> and
83
+ # <code>self.image</code> are finite.
83
84
  # * #hash: Returns the integer hash value for `self`.
84
85
  # * #imag (and its alias #imaginary): Returns the imaginary value for `self`.
85
- # * #infinite?: Returns whether `self.real` or `self.image` is infinite.
86
+ # * #infinite?: Returns whether <code>self.real</code> or
87
+ # <code>self.image</code> is infinite.
86
88
  # * #numerator: Returns the numerator of `self`.
87
- # * #polar: Returns the array `[self.abs, self.arg]`.
89
+ # * #polar: Returns the array <code>[self.abs, self.arg]</code>.
88
90
  # * #inspect: Returns a string representation of `self`.
89
91
  # * #real: Returns the real value for `self`.
90
92
  # * #real?: Returns `false`; for compatibility with Numeric#real?.
91
- # * #rect (and its alias #rectangular): Returns the array `[self.real,
92
- # self.imag]`.
93
+ # * #rect (and its alias #rectangular): Returns the array <code>[self.real,
94
+ # self.imag]</code>.
93
95
  #
94
96
  # ### Comparing
95
97
  #
@@ -100,12 +102,15 @@
100
102
  # ### Converting
101
103
  #
102
104
  # * #rationalize: Returns a Rational object whose value is exactly or
103
- # approximately equivalent to that of `self.real`.
105
+ # approximately equivalent to that of <code>self.real</code>.
104
106
  # * #to_c: Returns `self`.
105
107
  # * #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.
108
+ # * #to_f: Returns the value of <code>self.real</code> as a Float, if
109
+ # possible.
110
+ # * #to_i: Returns the value of <code>self.real</code> as an Integer, if
111
+ # possible.
112
+ # * #to_r: Returns the value of <code>self.real</code> as a Rational, if
113
+ # possible.
109
114
  # * #to_s: Returns a string representation of `self`.
110
115
  #
111
116
  # ### Performing Complex Arithmetic
@@ -118,7 +123,8 @@
118
123
  # * #/: Returns the quotient of `self` and the given numeric.
119
124
  # * #abs2: Returns square of the absolute value (magnitude) for `self`.
120
125
  # * #conj (and its alias #conjugate): Returns the conjugate of `self`.
121
- # * #fdiv: Returns `Complex.rect(self.real/numeric, self.imag/numeric)`.
126
+ # * #fdiv: Returns <code>Complex.rect(self.real/numeric,
127
+ # self.imag/numeric)</code>.
122
128
  #
123
129
  # ### Working with JSON
124
130
  #
@@ -283,10 +289,11 @@ class Complex < Numeric
283
289
  #
284
290
  # Returns:
285
291
  #
286
- # * `self.real <=> other.real` if both of the following are true:
292
+ # * <code>self.real <=> other.real</code> if both of the following are true:
287
293
  #
288
- # * `self.imag == 0`.
289
- # * `other.imag == 0` (always true if `other` is numeric but not complex).
294
+ # * <code>self.imag == 0</code>.
295
+ # * <code>other.imag == 0</code> (always true if `other` is numeric but
296
+ # not complex).
290
297
  #
291
298
  # * `nil` otherwise.
292
299
  #
@@ -308,7 +315,8 @@ class Complex < Numeric
308
315
  # rdoc-file=complex.c
309
316
  # - complex == object -> true or false
310
317
  # -->
311
- # Returns `true` if `self.real == object.real` and `self.imag == object.imag`:
318
+ # Returns `true` if <code>self.real == object.real</code> and <code>self.imag ==
319
+ # object.imag</code>:
312
320
  #
313
321
  # Complex.rect(2, 3) == Complex.rect(2.0, 3.0) # => true
314
322
  #
@@ -388,7 +396,8 @@ class Complex < Numeric
388
396
  def coerce: (Numeric) -> [ Complex, Complex ]
389
397
 
390
398
  # <!-- rdoc-file=complex.c -->
391
- # Returns the conjugate of `self`, `Complex.rect(self.imag, self.real)`:
399
+ # Returns the conjugate of `self`, <code>Complex.rect(self.imag,
400
+ # self.real)</code>:
392
401
  #
393
402
  # Complex.rect(1, 2).conj # => (1-2i)
394
403
  #
@@ -398,7 +407,8 @@ class Complex < Numeric
398
407
  # rdoc-file=complex.c
399
408
  # - conj -> complex
400
409
  # -->
401
- # Returns the conjugate of `self`, `Complex.rect(self.imag, self.real)`:
410
+ # Returns the conjugate of `self`, <code>Complex.rect(self.imag,
411
+ # self.real)</code>:
402
412
  #
403
413
  # Complex.rect(1, 2).conj # => (1-2i)
404
414
  #
@@ -410,11 +420,11 @@ class Complex < Numeric
410
420
  # -->
411
421
  # Returns the denominator of `self`, which is the [least common
412
422
  # multiple](https://en.wikipedia.org/wiki/Least_common_multiple) of
413
- # `self.real.denominator` and `self.imag.denominator`:
423
+ # <code>self.real.denominator</code> and <code>self.imag.denominator</code>:
414
424
  #
415
425
  # Complex.rect(Rational(1, 2), Rational(2, 3)).denominator # => 6
416
426
  #
417
- # Note that `n.denominator` of a non-rational numeric is `1`.
427
+ # Note that <code>n.denominator</code> of a non-rational numeric is `1`.
418
428
  #
419
429
  # Related: Complex#numerator.
420
430
  #
@@ -428,7 +438,7 @@ class Complex < Numeric
428
438
  # rdoc-file=complex.c
429
439
  # - fdiv(numeric) -> new_complex
430
440
  # -->
431
- # Returns `Complex.rect(self.real/numeric, self.imag/numeric)`:
441
+ # Returns <code>Complex.rect(self.real/numeric, self.imag/numeric)</code>:
432
442
  #
433
443
  # Complex.rect(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i)
434
444
  #
@@ -438,8 +448,8 @@ class Complex < Numeric
438
448
  # rdoc-file=complex.c
439
449
  # - finite? -> true or false
440
450
  # -->
441
- # Returns `true` if both `self.real.finite?` and `self.imag.finite?` are true,
442
- # `false` otherwise:
451
+ # Returns `true` if both <code>self.real.finite?</code> and
452
+ # <code>self.imag.finite?</code> are true, `false` otherwise:
443
453
  #
444
454
  # Complex.rect(1, 1).finite? # => true
445
455
  # Complex.rect(Float::INFINITY, 0).finite? # => false
@@ -467,7 +477,7 @@ class Complex < Numeric
467
477
  # rdoc-file=numeric.c
468
478
  # - i -> complex
469
479
  # -->
470
- # Returns `Complex(0, self)`:
480
+ # Returns <code>Complex(0, self)</code>:
471
481
  #
472
482
  # 2.i # => (0+2i)
473
483
  # -2.i # => (0-2i)
@@ -513,8 +523,8 @@ class Complex < Numeric
513
523
  # rdoc-file=complex.c
514
524
  # - infinite? -> 1 or nil
515
525
  # -->
516
- # Returns `1` if either `self.real.infinite?` or `self.imag.infinite?` is true,
517
- # `nil` otherwise:
526
+ # Returns `1` if either <code>self.real.infinite?</code> or
527
+ # <code>self.imag.infinite?</code> is true, `nil` otherwise:
518
528
  #
519
529
  # Complex.rect(Float::INFINITY, 0).infinite? # => 1
520
530
  # Complex.rect(1, 1).infinite? # => nil
@@ -570,7 +580,7 @@ class Complex < Numeric
570
580
  # In this example, the lowest common denominator of the two parts is 12; the two
571
581
  # converted parts may be thought of as Rational(8, 12) and Rational(9, 12),
572
582
  # whose numerators, respectively, are 8 and 9; so the returned value of
573
- # `c.numerator` is `Complex.rect(8, 9)`.
583
+ # <code>c.numerator</code> is <code>Complex.rect(8, 9)</code>.
574
584
  #
575
585
  # Related: Complex#denominator.
576
586
  #
@@ -594,7 +604,7 @@ class Complex < Numeric
594
604
  # rdoc-file=complex.c
595
605
  # - polar -> array
596
606
  # -->
597
- # Returns the array `[self.abs, self.arg]`:
607
+ # Returns the array <code>[self.abs, self.arg]</code>:
598
608
  #
599
609
  # Complex.polar(1, 2).polar # => [1.0, 2.0]
600
610
  #
@@ -629,17 +639,18 @@ class Complex < Numeric
629
639
  # - rationalize(epsilon = nil) -> rational
630
640
  # -->
631
641
  # Returns a Rational object whose value is exactly or approximately equivalent
632
- # to that of `self.real`.
642
+ # to that of <code>self.real</code>.
633
643
  #
634
644
  # With no argument `epsilon` given, returns a Rational object whose value is
635
- # exactly equal to that of `self.real.rationalize`:
645
+ # exactly equal to that of <code>self.real.rationalize</code>:
636
646
  #
637
647
  # Complex.rect(1, 0).rationalize # => (1/1)
638
648
  # Complex.rect(1, Rational(0, 1)).rationalize # => (1/1)
639
649
  # Complex.rect(3.14159, 0).rationalize # => (314159/100000)
640
650
  #
641
651
  # With argument `epsilon` given, returns a Rational object whose value is
642
- # exactly or approximately equal to that of `self.real` to the given precision:
652
+ # exactly or approximately equal to that of <code>self.real</code> to the given
653
+ # precision:
643
654
  #
644
655
  # Complex.rect(3.14159, 0).rationalize(0.1) # => (16/5)
645
656
  # Complex.rect(3.14159, 0).rationalize(0.01) # => (22/7)
@@ -700,7 +711,7 @@ class Complex < Numeric
700
711
  # rdoc-file=complex.c
701
712
  # - rect -> array
702
713
  # -->
703
- # Returns the array `[self.real, self.imag]`:
714
+ # Returns the array <code>[self.real, self.imag]</code>:
704
715
  #
705
716
  # Complex.rect(1, 2).rect # => [1, 2]
706
717
  #
@@ -734,13 +745,13 @@ class Complex < Numeric
734
745
  # rdoc-file=complex.c
735
746
  # - to_f -> float
736
747
  # -->
737
- # Returns the value of `self.real` as a Float, if possible:
748
+ # Returns the value of <code>self.real</code> as a Float, if possible:
738
749
  #
739
750
  # Complex.rect(1, 0).to_f # => 1.0
740
751
  # Complex.rect(1, Rational(0, 1)).to_f # => 1.0
741
752
  #
742
- # Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or
743
- # `Rational(0, *n*)`).
753
+ # Raises RangeError if <code>self.imag</code> is not exactly zero (either
754
+ # <code>Integer(0)</code> or <code>Rational(0, _n_)</code>).
744
755
  #
745
756
  def to_f: () -> Float
746
757
 
@@ -748,13 +759,13 @@ class Complex < Numeric
748
759
  # rdoc-file=complex.c
749
760
  # - to_i -> integer
750
761
  # -->
751
- # Returns the value of `self.real` as an Integer, if possible:
762
+ # Returns the value of <code>self.real</code> as an Integer, if possible:
752
763
  #
753
764
  # Complex.rect(1, 0).to_i # => 1
754
765
  # Complex.rect(1, Rational(0, 1)).to_i # => 1
755
766
  #
756
- # Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or
757
- # `Rational(0, *n*)`).
767
+ # Raises RangeError if <code>self.imag</code> is not exactly zero (either
768
+ # <code>Integer(0)</code> or <code>Rational(0, _n_)</code>).
758
769
  #
759
770
  def to_i: () -> Integer
760
771
 
@@ -762,14 +773,15 @@ class Complex < Numeric
762
773
  # rdoc-file=complex.c
763
774
  # - to_r -> rational
764
775
  # -->
765
- # Returns the value of `self.real` as a Rational, if possible:
776
+ # Returns the value of <code>self.real</code> as a Rational, if possible:
766
777
  #
767
778
  # Complex.rect(1, 0).to_r # => (1/1)
768
779
  # Complex.rect(1, Rational(0, 1)).to_r # => (1/1)
769
780
  # Complex.rect(1, 0.0).to_r # => (1/1)
770
781
  #
771
- # Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or
772
- # `Rational(0, *n*)`) and `self.imag.to_r` is not exactly zero.
782
+ # Raises RangeError if <code>self.imag</code> is not exactly zero (either
783
+ # <code>Integer(0)</code> or <code>Rational(0, _n_)</code>) and
784
+ # <code>self.imag.to_r</code> is not exactly zero.
773
785
  #
774
786
  # Related: Complex#rationalize.
775
787
  #
@@ -793,7 +805,7 @@ class Complex < Numeric
793
805
  end
794
806
 
795
807
  # <!-- rdoc-file=complex.c -->
796
- # Equivalent to `Complex.rect(0, 1)`:
808
+ # Equivalent to <code>Complex.rect(0, 1)</code>:
797
809
  #
798
810
  # Complex::I # => (0+1i)
799
811
  #