rbs 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.github/workflows/comments.yml +1 -1
 - data/CHANGELOG.md +6 -0
 - data/Gemfile.lock +1 -1
 - data/core/complex.rbs +290 -177
 - data/core/dir.rbs +22 -9
 - data/core/errors.rbs +1 -5
 - data/core/file.rbs +152 -37
 - data/core/float.rbs +4 -6
 - data/core/gc.rbs +1 -0
 - data/core/io/buffer.rbs +126 -47
 - data/core/io.rbs +9 -0
 - data/core/kernel.rbs +3 -3
 - data/core/match_data.rbs +24 -14
 - data/core/module.rbs +23 -18
 - data/core/numeric.rbs +13 -16
 - data/core/object_space/weak_key_map.rbs +78 -11
 - data/core/object_space.rbs +2 -0
 - data/core/process.rbs +4 -3
 - data/core/range.rbs +10 -9
 - data/core/refinement.rbs +10 -1
 - data/core/string.rbs +24 -25
 - data/core/thread.rbs +4 -4
 - data/core/trace_point.rbs +7 -4
 - data/lib/rbs/version.rb +1 -1
 - data/stdlib/bigdecimal/0/big_decimal.rbs +28 -29
 - data/stdlib/pty/0/pty.rbs +1 -7
 - data/stdlib/socket/0/addrinfo.rbs +4 -0
 - data/stdlib/socket/0/basic_socket.rbs +4 -2
 - data/stdlib/socket/0/socket.rbs +4 -3
 - data/stdlib/socket/0/udp_socket.rbs +4 -2
 - metadata +3 -3
 
    
        data/core/complex.rbs
    CHANGED
    
    | 
         @@ -36,6 +36,10 @@ 
     | 
|
| 
       36 
36 
     | 
    
         
             
            # *argument* parts; see [Complex polar
         
     | 
| 
       37 
37 
     | 
    
         
             
            # plane](https://en.wikipedia.org/wiki/Complex_number#Polar_complex_plane).
         
     | 
| 
       38 
38 
     | 
    
         
             
            #
         
     | 
| 
      
 39 
     | 
    
         
            +
            # In this class, the argument part in expressed
         
     | 
| 
      
 40 
     | 
    
         
            +
            # [radians](https://en.wikipedia.org/wiki/Radian) (not
         
     | 
| 
      
 41 
     | 
    
         
            +
            # [degrees](https://en.wikipedia.org/wiki/Degree_(angle))).
         
     | 
| 
      
 42 
     | 
    
         
            +
            #
         
     | 
| 
       39 
43 
     | 
    
         
             
            # You can create a Complex object from polar coordinates with:
         
     | 
| 
       40 
44 
     | 
    
         
             
            #
         
     | 
| 
       41 
45 
     | 
    
         
             
            # *   Method Complex.polar.
         
     | 
| 
         @@ -62,7 +66,7 @@ class Complex < Numeric 
     | 
|
| 
       62 
66 
     | 
    
         
             
              # -->
         
     | 
| 
       63 
67 
     | 
    
         
             
              # Returns a new Complex object formed from the arguments, each of which must be
         
     | 
| 
       64 
68 
     | 
    
         
             
              # an instance of Numeric, or an instance of one of its subclasses: Complex,
         
     | 
| 
       65 
     | 
    
         
            -
              # Float, Integer, Rational; see [Polar
         
     | 
| 
      
 69 
     | 
    
         
            +
              # Float, Integer, Rational. Argument `arg` is given in radians; see [Polar
         
     | 
| 
       66 
70 
     | 
    
         
             
              # Coordinates](rdoc-ref:Complex@Polar+Coordinates):
         
     | 
| 
       67 
71 
     | 
    
         
             
              #
         
     | 
| 
       68 
72 
     | 
    
         
             
              #     Complex.polar(3)        # => (3+0i)
         
     | 
| 
         @@ -109,40 +113,40 @@ class Complex < Numeric 
     | 
|
| 
       109 
113 
     | 
    
         | 
| 
       110 
114 
     | 
    
         
             
              # <!--
         
     | 
| 
       111 
115 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       112 
     | 
    
         
            -
              #   -  
     | 
| 
      
 116 
     | 
    
         
            +
              #   - complex * numeric -> new_complex
         
     | 
| 
       113 
117 
     | 
    
         
             
              # -->
         
     | 
| 
       114 
     | 
    
         
            -
              #  
     | 
| 
      
 118 
     | 
    
         
            +
              # Returns the product of `self` and `numeric`:
         
     | 
| 
       115 
119 
     | 
    
         
             
              #
         
     | 
| 
       116 
     | 
    
         
            -
              #     Complex(2, 3)  * Complex(2, 3) 
     | 
| 
       117 
     | 
    
         
            -
              #     Complex(900)   * Complex(1) 
     | 
| 
       118 
     | 
    
         
            -
              #     Complex(-2, 9) * Complex(-9, 2) 
     | 
| 
       119 
     | 
    
         
            -
              #     Complex(9, 8)  * 4 
     | 
| 
       120 
     | 
    
         
            -
              #     Complex(20, 9) * 9.8 
     | 
| 
      
 120 
     | 
    
         
            +
              #     Complex(2, 3)  * Complex(2, 3)  # => (-5+12i)
         
     | 
| 
      
 121 
     | 
    
         
            +
              #     Complex(900)   * Complex(1)     # => (900+0i)
         
     | 
| 
      
 122 
     | 
    
         
            +
              #     Complex(-2, 9) * Complex(-9, 2) # => (0-85i)
         
     | 
| 
      
 123 
     | 
    
         
            +
              #     Complex(9, 8)  * 4              # => (36+32i)
         
     | 
| 
      
 124 
     | 
    
         
            +
              #     Complex(20, 9) * 9.8            # => (196.0+88.2i)
         
     | 
| 
       121 
125 
     | 
    
         
             
              #
         
     | 
| 
       122 
126 
     | 
    
         
             
              def *: (Numeric) -> Complex
         
     | 
| 
       123 
127 
     | 
    
         | 
| 
       124 
128 
     | 
    
         
             
              # <!--
         
     | 
| 
       125 
129 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       126 
     | 
    
         
            -
              #   -  
     | 
| 
      
 130 
     | 
    
         
            +
              #   - complex ** numeric -> new_complex
         
     | 
| 
       127 
131 
     | 
    
         
             
              # -->
         
     | 
| 
       128 
     | 
    
         
            -
              #  
     | 
| 
      
 132 
     | 
    
         
            +
              # Returns `self` raised to power `numeric`:
         
     | 
| 
       129 
133 
     | 
    
         
             
              #
         
     | 
| 
       130 
     | 
    
         
            -
              #     Complex('i') ** 2 
     | 
| 
       131 
     | 
    
         
            -
              #     Complex(-8) ** Rational(1, 3) 
     | 
| 
      
 134 
     | 
    
         
            +
              #     Complex('i') ** 2             # => (-1+0i)
         
     | 
| 
      
 135 
     | 
    
         
            +
              #     Complex(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
         
     | 
| 
       132 
136 
     | 
    
         
             
              #
         
     | 
| 
       133 
137 
     | 
    
         
             
              def **: (Numeric) -> Complex
         
     | 
| 
       134 
138 
     | 
    
         | 
| 
       135 
139 
     | 
    
         
             
              # <!--
         
     | 
| 
       136 
140 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       137 
     | 
    
         
            -
              #   -  
     | 
| 
      
 141 
     | 
    
         
            +
              #   - complex + numeric -> new_complex
         
     | 
| 
       138 
142 
     | 
    
         
             
              # -->
         
     | 
| 
       139 
     | 
    
         
            -
              #  
     | 
| 
      
 143 
     | 
    
         
            +
              # Returns the sum of `self` and `numeric`:
         
     | 
| 
       140 
144 
     | 
    
         
             
              #
         
     | 
| 
       141 
     | 
    
         
            -
              #     Complex(2, 3)  + Complex(2, 3) 
     | 
| 
       142 
     | 
    
         
            -
              #     Complex(900)   + Complex(1) 
     | 
| 
       143 
     | 
    
         
            -
              #     Complex(-2, 9) + Complex(-9, 2) 
     | 
| 
       144 
     | 
    
         
            -
              #     Complex(9, 8)  + 4 
     | 
| 
       145 
     | 
    
         
            -
              #     Complex(20, 9) + 9.8 
     | 
| 
      
 145 
     | 
    
         
            +
              #     Complex(2, 3)  + Complex(2, 3)  # => (4+6i)
         
     | 
| 
      
 146 
     | 
    
         
            +
              #     Complex(900)   + Complex(1)     # => (901+0i)
         
     | 
| 
      
 147 
     | 
    
         
            +
              #     Complex(-2, 9) + Complex(-9, 2) # => (-11+11i)
         
     | 
| 
      
 148 
     | 
    
         
            +
              #     Complex(9, 8)  + 4              # => (13+8i)
         
     | 
| 
      
 149 
     | 
    
         
            +
              #     Complex(20, 9) + 9.8            # => (29.8+9i)
         
     | 
| 
       146 
150 
     | 
    
         
             
              #
         
     | 
| 
       147 
151 
     | 
    
         
             
              def +: (Numeric) -> Complex
         
     | 
| 
       148 
152 
     | 
    
         | 
| 
         @@ -150,40 +154,40 @@ class Complex < Numeric 
     | 
|
| 
       150 
154 
     | 
    
         | 
| 
       151 
155 
     | 
    
         
             
              # <!--
         
     | 
| 
       152 
156 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       153 
     | 
    
         
            -
              #   -  
     | 
| 
      
 157 
     | 
    
         
            +
              #   - complex - numeric -> new_complex
         
     | 
| 
       154 
158 
     | 
    
         
             
              # -->
         
     | 
| 
       155 
     | 
    
         
            -
              #  
     | 
| 
      
 159 
     | 
    
         
            +
              # Returns the difference of `self` and `numeric`:
         
     | 
| 
       156 
160 
     | 
    
         
             
              #
         
     | 
| 
       157 
     | 
    
         
            -
              #     Complex(2, 3)  - Complex(2, 3) 
     | 
| 
       158 
     | 
    
         
            -
              #     Complex(900)   - Complex(1) 
     | 
| 
       159 
     | 
    
         
            -
              #     Complex(-2, 9) - Complex(-9, 2) 
     | 
| 
       160 
     | 
    
         
            -
              #     Complex(9, 8)  - 4 
     | 
| 
       161 
     | 
    
         
            -
              #     Complex(20, 9) - 9.8 
     | 
| 
      
 161 
     | 
    
         
            +
              #     Complex(2, 3)  - Complex(2, 3)  # => (0+0i)
         
     | 
| 
      
 162 
     | 
    
         
            +
              #     Complex(900)   - Complex(1)     # => (899+0i)
         
     | 
| 
      
 163 
     | 
    
         
            +
              #     Complex(-2, 9) - Complex(-9, 2) # => (7+7i)
         
     | 
| 
      
 164 
     | 
    
         
            +
              #     Complex(9, 8)  - 4              # => (5+8i)
         
     | 
| 
      
 165 
     | 
    
         
            +
              #     Complex(20, 9) - 9.8            # => (10.2+9i)
         
     | 
| 
       162 
166 
     | 
    
         
             
              #
         
     | 
| 
       163 
167 
     | 
    
         
             
              def -: (Numeric) -> Complex
         
     | 
| 
       164 
168 
     | 
    
         | 
| 
       165 
169 
     | 
    
         
             
              # <!--
         
     | 
| 
       166 
170 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       167 
     | 
    
         
            -
              #   - - 
     | 
| 
      
 171 
     | 
    
         
            +
              #   - -complex -> new_complex
         
     | 
| 
       168 
172 
     | 
    
         
             
              # -->
         
     | 
| 
       169 
     | 
    
         
            -
              # Returns negation of the  
     | 
| 
      
 173 
     | 
    
         
            +
              # Returns the negation of `self`, which is the negation of each of its parts:
         
     | 
| 
       170 
174 
     | 
    
         
             
              #
         
     | 
| 
       171 
     | 
    
         
            -
              #     -Complex(1, 2) 
     | 
| 
      
 175 
     | 
    
         
            +
              #     -Complex(1, 2)   # => (-1-2i)
         
     | 
| 
      
 176 
     | 
    
         
            +
              #     -Complex(-1, -2) # => (1+2i)
         
     | 
| 
       172 
177 
     | 
    
         
             
              #
         
     | 
| 
       173 
178 
     | 
    
         
             
              def -@: () -> Complex
         
     | 
| 
       174 
179 
     | 
    
         | 
| 
       175 
180 
     | 
    
         
             
              # <!--
         
     | 
| 
       176 
181 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       177 
     | 
    
         
            -
              #   -  
     | 
| 
       178 
     | 
    
         
            -
              #   - cmp.quo(numeric)  ->  complex
         
     | 
| 
      
 182 
     | 
    
         
            +
              #   - complex / numeric -> new_complex
         
     | 
| 
       179 
183 
     | 
    
         
             
              # -->
         
     | 
| 
       180 
     | 
    
         
            -
              #  
     | 
| 
      
 184 
     | 
    
         
            +
              # Returns the quotient of `self` and `numeric`:
         
     | 
| 
       181 
185 
     | 
    
         
             
              #
         
     | 
| 
       182 
     | 
    
         
            -
              #     Complex(2, 3)  / Complex(2, 3) 
     | 
| 
       183 
     | 
    
         
            -
              #     Complex(900)   / Complex(1) 
     | 
| 
       184 
     | 
    
         
            -
              #     Complex(-2, 9) / Complex(-9, 2) 
     | 
| 
       185 
     | 
    
         
            -
              #     Complex(9, 8)  / 4 
     | 
| 
       186 
     | 
    
         
            -
              #     Complex(20, 9) / 9.8 
     | 
| 
      
 186 
     | 
    
         
            +
              #     Complex(2, 3)  / Complex(2, 3)  # => ((1/1)+(0/1)*i)
         
     | 
| 
      
 187 
     | 
    
         
            +
              #     Complex(900)   / Complex(1)     # => ((900/1)+(0/1)*i)
         
     | 
| 
      
 188 
     | 
    
         
            +
              #     Complex(-2, 9) / Complex(-9, 2) # => ((36/85)-(77/85)*i)
         
     | 
| 
      
 189 
     | 
    
         
            +
              #     Complex(9, 8)  / 4              # => ((9/4)+(2/1)*i)
         
     | 
| 
      
 190 
     | 
    
         
            +
              #     Complex(20, 9) / 9.8            # => (2.0408163265306123+0.9183673469387754i)
         
     | 
| 
       187 
191 
     | 
    
         
             
              #
         
     | 
| 
       188 
192 
     | 
    
         
             
              def /: (Numeric) -> Complex
         
     | 
| 
       189 
193 
     | 
    
         | 
| 
         @@ -193,31 +197,38 @@ class Complex < Numeric 
     | 
|
| 
       193 
197 
     | 
    
         | 
| 
       194 
198 
     | 
    
         
             
              # <!--
         
     | 
| 
       195 
199 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       196 
     | 
    
         
            -
              #   -  
     | 
| 
      
 200 
     | 
    
         
            +
              #   - complex <=> object -> -1, 0, 1, or nil
         
     | 
| 
       197 
201 
     | 
    
         
             
              # -->
         
     | 
| 
       198 
     | 
    
         
            -
              #  
     | 
| 
       199 
     | 
    
         
            -
              # 
     | 
| 
       200 
     | 
    
         
            -
              # ` 
     | 
| 
      
 202 
     | 
    
         
            +
              # Returns:
         
     | 
| 
      
 203 
     | 
    
         
            +
              #
         
     | 
| 
      
 204 
     | 
    
         
            +
              # *   `self.real <=> object.real` if both of the following are true:
         
     | 
| 
      
 205 
     | 
    
         
            +
              #
         
     | 
| 
      
 206 
     | 
    
         
            +
              #     *   `self.imag == 0`.
         
     | 
| 
      
 207 
     | 
    
         
            +
              #     *   `object.imag == 0`. # Always true if object is numeric but not
         
     | 
| 
      
 208 
     | 
    
         
            +
              #         complex.
         
     | 
| 
      
 209 
     | 
    
         
            +
              #
         
     | 
| 
      
 210 
     | 
    
         
            +
              #
         
     | 
| 
      
 211 
     | 
    
         
            +
              # *   `nil` otherwise.
         
     | 
| 
      
 212 
     | 
    
         
            +
              #
         
     | 
| 
       201 
213 
     | 
    
         
             
              #
         
     | 
| 
       202 
     | 
    
         
            -
              # 
     | 
| 
       203 
     | 
    
         
            -
              # 
     | 
| 
       204 
     | 
    
         
            -
              #     Complex(2) 
     | 
| 
       205 
     | 
    
         
            -
              #     Complex(2) 
     | 
| 
       206 
     | 
    
         
            -
              #     Complex(2) 
     | 
| 
      
 214 
     | 
    
         
            +
              # Examples:
         
     | 
| 
      
 215 
     | 
    
         
            +
              #
         
     | 
| 
      
 216 
     | 
    
         
            +
              #     Complex(2) <=> 3             # => -1
         
     | 
| 
      
 217 
     | 
    
         
            +
              #     Complex(2) <=> 2             # => 0
         
     | 
| 
      
 218 
     | 
    
         
            +
              #     Complex(2) <=> 1             # => 1
         
     | 
| 
      
 219 
     | 
    
         
            +
              #     Complex(2, 1) <=> 1          # => nil # self.imag not zero.
         
     | 
| 
      
 220 
     | 
    
         
            +
              #     Complex(1) <=> Complex(1, 1) # => nil # object.imag not zero.
         
     | 
| 
      
 221 
     | 
    
         
            +
              #     Complex(1) <=> 'Foo'         # => nil # object.imag not defined.
         
     | 
| 
       207 
222 
     | 
    
         
             
              #
         
     | 
| 
       208 
223 
     | 
    
         
             
              def <=>: (untyped) -> Integer?
         
     | 
| 
       209 
224 
     | 
    
         | 
| 
       210 
225 
     | 
    
         
             
              # <!--
         
     | 
| 
       211 
226 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       212 
     | 
    
         
            -
              #   -  
     | 
| 
      
 227 
     | 
    
         
            +
              #   - complex == object -> true or false
         
     | 
| 
       213 
228 
     | 
    
         
             
              # -->
         
     | 
| 
       214 
     | 
    
         
            -
              # Returns true if  
     | 
| 
      
 229 
     | 
    
         
            +
              # Returns `true` if `self.real == object.real` and `self.imag == object.imag`:
         
     | 
| 
       215 
230 
     | 
    
         
             
              #
         
     | 
| 
       216 
     | 
    
         
            -
              #     Complex(2, 3)  == Complex(2, 3) 
     | 
| 
       217 
     | 
    
         
            -
              #     Complex(5)     == 5               #=> true
         
     | 
| 
       218 
     | 
    
         
            -
              #     Complex(0)     == 0.0             #=> true
         
     | 
| 
       219 
     | 
    
         
            -
              #     Complex('1/3') == 0.33            #=> false
         
     | 
| 
       220 
     | 
    
         
            -
              #     Complex('1/2') == '1/2'           #=> false
         
     | 
| 
      
 231 
     | 
    
         
            +
              #     Complex(2, 3)  == Complex(2.0, 3.0)      # => true
         
     | 
| 
       221 
232 
     | 
    
         
             
              #
         
     | 
| 
       222 
233 
     | 
    
         
             
              def ==: (untyped) -> bool
         
     | 
| 
       223 
234 
     | 
    
         | 
| 
         @@ -227,43 +238,66 @@ class Complex < Numeric 
     | 
|
| 
       227 
238 
     | 
    
         | 
| 
       228 
239 
     | 
    
         
             
              # <!--
         
     | 
| 
       229 
240 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       230 
     | 
    
         
            -
              #   -  
     | 
| 
       231 
     | 
    
         
            -
              #   - cmp.magnitude  ->  real
         
     | 
| 
      
 241 
     | 
    
         
            +
              #   - abs -> float
         
     | 
| 
       232 
242 
     | 
    
         
             
              # -->
         
     | 
| 
       233 
     | 
    
         
            -
              # Returns the absolute  
     | 
| 
      
 243 
     | 
    
         
            +
              # Returns the absolute value (magnitude) for `self`; see [polar
         
     | 
| 
      
 244 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Polar+Coordinates):
         
     | 
| 
      
 245 
     | 
    
         
            +
              #
         
     | 
| 
      
 246 
     | 
    
         
            +
              #     Complex.polar(-1, 0).abs # => 1.0
         
     | 
| 
      
 247 
     | 
    
         
            +
              #
         
     | 
| 
      
 248 
     | 
    
         
            +
              # If `self` was created with [rectangular
         
     | 
| 
      
 249 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is
         
     | 
| 
      
 250 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
       234 
251 
     | 
    
         
             
              #
         
     | 
| 
       235 
     | 
    
         
            -
              #     Complex( 
     | 
| 
       236 
     | 
    
         
            -
              #     Complex(3.0, -4.0).abs  #=> 5.0
         
     | 
| 
      
 252 
     | 
    
         
            +
              #     Complex.rectangular(1, 1).abs # => 1.4142135623730951 # The square root of 2.
         
     | 
| 
       237 
253 
     | 
    
         
             
              #
         
     | 
| 
       238 
254 
     | 
    
         
             
              def abs: () -> Numeric
         
     | 
| 
       239 
255 
     | 
    
         | 
| 
       240 
256 
     | 
    
         
             
              # <!--
         
     | 
| 
       241 
257 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       242 
     | 
    
         
            -
              #   -  
     | 
| 
      
 258 
     | 
    
         
            +
              #   - abs2 -> float
         
     | 
| 
       243 
259 
     | 
    
         
             
              # -->
         
     | 
| 
       244 
     | 
    
         
            -
              # Returns square of the absolute value 
     | 
| 
      
 260 
     | 
    
         
            +
              # Returns square of the absolute value (magnitude) for `self`; see [polar
         
     | 
| 
      
 261 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Polar+Coordinates):
         
     | 
| 
       245 
262 
     | 
    
         
             
              #
         
     | 
| 
       246 
     | 
    
         
            -
              #     Complex( 
     | 
| 
       247 
     | 
    
         
            -
              # 
     | 
| 
      
 263 
     | 
    
         
            +
              #     Complex.polar(2, 2).abs2 # => 4.0
         
     | 
| 
      
 264 
     | 
    
         
            +
              #
         
     | 
| 
      
 265 
     | 
    
         
            +
              # If `self` was created with [rectangular
         
     | 
| 
      
 266 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is
         
     | 
| 
      
 267 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
      
 268 
     | 
    
         
            +
              #
         
     | 
| 
      
 269 
     | 
    
         
            +
              #     Complex.rectangular(1.0/3, 1.0/3).abs2 # => 0.2222222222222222
         
     | 
| 
       248 
270 
     | 
    
         
             
              #
         
     | 
| 
       249 
271 
     | 
    
         
             
              def abs2: () -> Numeric
         
     | 
| 
       250 
272 
     | 
    
         | 
| 
       251 
273 
     | 
    
         
             
              # <!-- rdoc-file=complex.c -->
         
     | 
| 
       252 
     | 
    
         
            -
              # Returns the angle  
     | 
| 
      
 274 
     | 
    
         
            +
              # Returns the argument (angle) for `self` in radians; see [polar
         
     | 
| 
      
 275 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Polar+Coordinates):
         
     | 
| 
      
 276 
     | 
    
         
            +
              #
         
     | 
| 
      
 277 
     | 
    
         
            +
              #     Complex.polar(3, Math::PI/2).arg  # => 1.57079632679489660
         
     | 
| 
       253 
278 
     | 
    
         
             
              #
         
     | 
| 
       254 
     | 
    
         
            -
              # 
     | 
| 
      
 279 
     | 
    
         
            +
              # If `self` was created with [rectangular
         
     | 
| 
      
 280 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is
         
     | 
| 
      
 281 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
      
 282 
     | 
    
         
            +
              #
         
     | 
| 
      
 283 
     | 
    
         
            +
              #     Complex.polar(1, 1.0/3).arg # => 0.33333333333333326
         
     | 
| 
       255 
284 
     | 
    
         
             
              #
         
     | 
| 
       256 
285 
     | 
    
         
             
              def angle: () -> Float
         
     | 
| 
       257 
286 
     | 
    
         | 
| 
       258 
287 
     | 
    
         
             
              # <!--
         
     | 
| 
       259 
288 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       260 
     | 
    
         
            -
              #   -  
     | 
| 
       261 
     | 
    
         
            -
              #   - cmp.angle  ->  float
         
     | 
| 
       262 
     | 
    
         
            -
              #   - cmp.phase  ->  float
         
     | 
| 
      
 289 
     | 
    
         
            +
              #   - arg -> float
         
     | 
| 
       263 
290 
     | 
    
         
             
              # -->
         
     | 
| 
       264 
     | 
    
         
            -
              # Returns the angle  
     | 
| 
      
 291 
     | 
    
         
            +
              # Returns the argument (angle) for `self` in radians; see [polar
         
     | 
| 
      
 292 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Polar+Coordinates):
         
     | 
| 
      
 293 
     | 
    
         
            +
              #
         
     | 
| 
      
 294 
     | 
    
         
            +
              #     Complex.polar(3, Math::PI/2).arg  # => 1.57079632679489660
         
     | 
| 
      
 295 
     | 
    
         
            +
              #
         
     | 
| 
      
 296 
     | 
    
         
            +
              # If `self` was created with [rectangular
         
     | 
| 
      
 297 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is
         
     | 
| 
      
 298 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
       265 
299 
     | 
    
         
             
              #
         
     | 
| 
       266 
     | 
    
         
            -
              #     Complex.polar( 
     | 
| 
      
 300 
     | 
    
         
            +
              #     Complex.polar(1, 1.0/3).arg # => 0.33333333333333326
         
     | 
| 
       267 
301 
     | 
    
         
             
              #
         
     | 
| 
       268 
302 
     | 
    
         
             
              alias arg angle
         
     | 
| 
       269 
303 
     | 
    
         | 
| 
         @@ -272,30 +306,35 @@ class Complex < Numeric 
     | 
|
| 
       272 
306 
     | 
    
         
             
              def coerce: (Numeric) -> [ Complex, Complex ]
         
     | 
| 
       273 
307 
     | 
    
         | 
| 
       274 
308 
     | 
    
         
             
              # <!-- rdoc-file=complex.c -->
         
     | 
| 
       275 
     | 
    
         
            -
              # Returns the  
     | 
| 
      
 309 
     | 
    
         
            +
              # Returns the conjugate of `self`, `Complex.rect(self.imag, self.real)`:
         
     | 
| 
       276 
310 
     | 
    
         
             
              #
         
     | 
| 
       277 
     | 
    
         
            -
              #     Complex(1, 2). 
     | 
| 
      
 311 
     | 
    
         
            +
              #     Complex.rect(1, 2).conj # => (1-2i)
         
     | 
| 
       278 
312 
     | 
    
         
             
              #
         
     | 
| 
       279 
313 
     | 
    
         
             
              def conj: () -> Complex
         
     | 
| 
       280 
314 
     | 
    
         | 
| 
       281 
315 
     | 
    
         
             
              # <!--
         
     | 
| 
       282 
316 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       283 
     | 
    
         
            -
              #   -  
     | 
| 
       284 
     | 
    
         
            -
              #   - cmp.conjugate  ->  complex
         
     | 
| 
      
 317 
     | 
    
         
            +
              #   - conj -> complex
         
     | 
| 
       285 
318 
     | 
    
         
             
              # -->
         
     | 
| 
       286 
     | 
    
         
            -
              # Returns the  
     | 
| 
      
 319 
     | 
    
         
            +
              # Returns the conjugate of `self`, `Complex.rect(self.imag, self.real)`:
         
     | 
| 
       287 
320 
     | 
    
         
             
              #
         
     | 
| 
       288 
     | 
    
         
            -
              #     Complex(1, 2). 
     | 
| 
      
 321 
     | 
    
         
            +
              #     Complex.rect(1, 2).conj # => (1-2i)
         
     | 
| 
       289 
322 
     | 
    
         
             
              #
         
     | 
| 
       290 
323 
     | 
    
         
             
              def conjugate: () -> Complex
         
     | 
| 
       291 
324 
     | 
    
         | 
| 
       292 
325 
     | 
    
         
             
              # <!--
         
     | 
| 
       293 
326 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       294 
     | 
    
         
            -
              #   -  
     | 
| 
      
 327 
     | 
    
         
            +
              #   - denominator -> integer
         
     | 
| 
       295 
328 
     | 
    
         
             
              # -->
         
     | 
| 
       296 
     | 
    
         
            -
              # Returns the denominator  
     | 
| 
      
 329 
     | 
    
         
            +
              # Returns the denominator of `self`, which is the [least common
         
     | 
| 
      
 330 
     | 
    
         
            +
              # multiple](https://en.wikipedia.org/wiki/Least_common_multiple) of
         
     | 
| 
      
 331 
     | 
    
         
            +
              # `self.real.denominator` and `self.imag.denominator`:
         
     | 
| 
       297 
332 
     | 
    
         
             
              #
         
     | 
| 
       298 
     | 
    
         
            -
              #  
     | 
| 
      
 333 
     | 
    
         
            +
              #     Complex.rect(Rational(1, 2), Rational(2, 3)).denominator # => 6
         
     | 
| 
      
 334 
     | 
    
         
            +
              #
         
     | 
| 
      
 335 
     | 
    
         
            +
              # Note that `n.denominator` of a non-rational numeric is `1`.
         
     | 
| 
      
 336 
     | 
    
         
            +
              #
         
     | 
| 
      
 337 
     | 
    
         
            +
              # Related: Complex#numerator.
         
     | 
| 
       299 
338 
     | 
    
         
             
              #
         
     | 
| 
       300 
339 
     | 
    
         
             
              def denominator: () -> Integer
         
     | 
| 
       301 
340 
     | 
    
         | 
| 
         @@ -309,20 +348,25 @@ class Complex < Numeric 
     | 
|
| 
       309 
348 
     | 
    
         | 
| 
       310 
349 
     | 
    
         
             
              # <!--
         
     | 
| 
       311 
350 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       312 
     | 
    
         
            -
              #   -  
     | 
| 
      
 351 
     | 
    
         
            +
              #   - fdiv(numeric) -> new_complex
         
     | 
| 
       313 
352 
     | 
    
         
             
              # -->
         
     | 
| 
       314 
     | 
    
         
            -
              #  
     | 
| 
      
 353 
     | 
    
         
            +
              # Returns `Complex(self.real/numeric, self.imag/numeric)`:
         
     | 
| 
       315 
354 
     | 
    
         
             
              #
         
     | 
| 
       316 
     | 
    
         
            -
              #     Complex(11, 22).fdiv(3) 
     | 
| 
      
 355 
     | 
    
         
            +
              #     Complex(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i)
         
     | 
| 
       317 
356 
     | 
    
         
             
              #
         
     | 
| 
       318 
357 
     | 
    
         
             
              def fdiv: (Numeric) -> Complex
         
     | 
| 
       319 
358 
     | 
    
         | 
| 
       320 
359 
     | 
    
         
             
              # <!--
         
     | 
| 
       321 
360 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       322 
     | 
    
         
            -
              #   -  
     | 
| 
      
 361 
     | 
    
         
            +
              #   - finite? -> true or false
         
     | 
| 
       323 
362 
     | 
    
         
             
              # -->
         
     | 
| 
       324 
     | 
    
         
            -
              # Returns `true` if ` 
     | 
| 
       325 
     | 
    
         
            -
              #  
     | 
| 
      
 363 
     | 
    
         
            +
              # Returns `true` if both `self.real.finite?` and `self.imag.finite?` are true,
         
     | 
| 
      
 364 
     | 
    
         
            +
              # `false` otherwise:
         
     | 
| 
      
 365 
     | 
    
         
            +
              #
         
     | 
| 
      
 366 
     | 
    
         
            +
              #     Complex(1, 1).finite?               # => true
         
     | 
| 
      
 367 
     | 
    
         
            +
              #     Complex(Float::INFINITY, 0).finite? # => false
         
     | 
| 
      
 368 
     | 
    
         
            +
              #
         
     | 
| 
      
 369 
     | 
    
         
            +
              # Related: Numeric#finite?, Float#finite?.
         
     | 
| 
       326 
370 
     | 
    
         
             
              #
         
     | 
| 
       327 
371 
     | 
    
         
             
              def finite?: () -> bool
         
     | 
| 
       328 
372 
     | 
    
         | 
| 
         @@ -330,68 +374,91 @@ class Complex < Numeric 
     | 
|
| 
       330 
374 
     | 
    
         | 
| 
       331 
375 
     | 
    
         
             
              # <!--
         
     | 
| 
       332 
376 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       333 
     | 
    
         
            -
              #   - hash 
     | 
| 
      
 377 
     | 
    
         
            +
              #   - hash -> integer
         
     | 
| 
       334 
378 
     | 
    
         
             
              # -->
         
     | 
| 
      
 379 
     | 
    
         
            +
              # Returns the integer hash value for `self`.
         
     | 
| 
      
 380 
     | 
    
         
            +
              #
         
     | 
| 
      
 381 
     | 
    
         
            +
              # Two Complex objects created from the same values will have the same hash value
         
     | 
| 
      
 382 
     | 
    
         
            +
              # (and will compare using #eql?):
         
     | 
| 
      
 383 
     | 
    
         
            +
              #
         
     | 
| 
      
 384 
     | 
    
         
            +
              #     Complex(1, 2).hash == Complex(1, 2).hash # => true
         
     | 
| 
       335 
385 
     | 
    
         
             
              #
         
     | 
| 
       336 
386 
     | 
    
         
             
              def hash: () -> Integer
         
     | 
| 
       337 
387 
     | 
    
         | 
| 
       338 
388 
     | 
    
         
             
              def i: () -> bot
         
     | 
| 
       339 
389 
     | 
    
         | 
| 
       340 
390 
     | 
    
         
             
              # <!-- rdoc-file=complex.c -->
         
     | 
| 
       341 
     | 
    
         
            -
              # Returns the imaginary  
     | 
| 
      
 391 
     | 
    
         
            +
              # Returns the imaginary value for `self`:
         
     | 
| 
       342 
392 
     | 
    
         
             
              #
         
     | 
| 
       343 
393 
     | 
    
         
             
              #     Complex(7).imaginary      #=> 0
         
     | 
| 
       344 
394 
     | 
    
         
             
              #     Complex(9, -4).imaginary  #=> -4
         
     | 
| 
       345 
395 
     | 
    
         
             
              #
         
     | 
| 
      
 396 
     | 
    
         
            +
              # If `self` was created with [polar
         
     | 
| 
      
 397 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is
         
     | 
| 
      
 398 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
      
 399 
     | 
    
         
            +
              #
         
     | 
| 
      
 400 
     | 
    
         
            +
              #     Complex.polar(1, Math::PI/4).imag # => 0.7071067811865476 # Square root of 2.
         
     | 
| 
      
 401 
     | 
    
         
            +
              #
         
     | 
| 
       346 
402 
     | 
    
         
             
              def imag: () -> Numeric
         
     | 
| 
       347 
403 
     | 
    
         | 
| 
       348 
404 
     | 
    
         
             
              # <!--
         
     | 
| 
       349 
405 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       350 
     | 
    
         
            -
              #   -  
     | 
| 
       351 
     | 
    
         
            -
              #   - cmp.imaginary  ->  real
         
     | 
| 
      
 406 
     | 
    
         
            +
              #   - imag -> numeric
         
     | 
| 
       352 
407 
     | 
    
         
             
              # -->
         
     | 
| 
       353 
     | 
    
         
            -
              # Returns the imaginary  
     | 
| 
      
 408 
     | 
    
         
            +
              # Returns the imaginary value for `self`:
         
     | 
| 
       354 
409 
     | 
    
         
             
              #
         
     | 
| 
       355 
410 
     | 
    
         
             
              #     Complex(7).imaginary      #=> 0
         
     | 
| 
       356 
411 
     | 
    
         
             
              #     Complex(9, -4).imaginary  #=> -4
         
     | 
| 
       357 
412 
     | 
    
         
             
              #
         
     | 
| 
      
 413 
     | 
    
         
            +
              # If `self` was created with [polar
         
     | 
| 
      
 414 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is
         
     | 
| 
      
 415 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
      
 416 
     | 
    
         
            +
              #
         
     | 
| 
      
 417 
     | 
    
         
            +
              #     Complex.polar(1, Math::PI/4).imag # => 0.7071067811865476 # Square root of 2.
         
     | 
| 
      
 418 
     | 
    
         
            +
              #
         
     | 
| 
       358 
419 
     | 
    
         
             
              def imaginary: () -> Numeric
         
     | 
| 
       359 
420 
     | 
    
         | 
| 
       360 
421 
     | 
    
         
             
              # <!--
         
     | 
| 
       361 
422 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       362 
     | 
    
         
            -
              #   -  
     | 
| 
      
 423 
     | 
    
         
            +
              #   - infinite? -> 1 or nil
         
     | 
| 
       363 
424 
     | 
    
         
             
              # -->
         
     | 
| 
       364 
     | 
    
         
            -
              # Returns `1` if ` 
     | 
| 
       365 
     | 
    
         
            -
              #  
     | 
| 
      
 425 
     | 
    
         
            +
              # Returns `1` if either `self.real.infinite?` or `self.imag.infinite?` is true,
         
     | 
| 
      
 426 
     | 
    
         
            +
              # `nil` otherwise:
         
     | 
| 
       366 
427 
     | 
    
         
             
              #
         
     | 
| 
       367 
     | 
    
         
            -
              #      
     | 
| 
      
 428 
     | 
    
         
            +
              #     Complex(Float::INFINITY, 0).infinite? # => 1
         
     | 
| 
      
 429 
     | 
    
         
            +
              #     Complex(1, 1).infinite?               # => nil
         
     | 
| 
       368 
430 
     | 
    
         
             
              #
         
     | 
| 
       369 
     | 
    
         
            -
              # 
     | 
| 
       370 
     | 
    
         
            -
              #        (Float::INFINITY + 1i).infinite?   #=> 1
         
     | 
| 
      
 431 
     | 
    
         
            +
              # Related: Numeric#infinite?, Float#infinite?.
         
     | 
| 
       371 
432 
     | 
    
         
             
              #
         
     | 
| 
       372 
433 
     | 
    
         
             
              def infinite?: () -> Integer?
         
     | 
| 
       373 
434 
     | 
    
         | 
| 
       374 
435 
     | 
    
         
             
              # <!--
         
     | 
| 
       375 
436 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       376 
     | 
    
         
            -
              #   -  
     | 
| 
      
 437 
     | 
    
         
            +
              #   - inspect -> string
         
     | 
| 
       377 
438 
     | 
    
         
             
              # -->
         
     | 
| 
       378 
     | 
    
         
            -
              # Returns  
     | 
| 
      
 439 
     | 
    
         
            +
              # Returns a string representation of `self`:
         
     | 
| 
       379 
440 
     | 
    
         
             
              #
         
     | 
| 
       380 
     | 
    
         
            -
              #     Complex(2).inspect 
     | 
| 
       381 
     | 
    
         
            -
              #     Complex('-8/6').inspect 
     | 
| 
       382 
     | 
    
         
            -
              #     Complex('1/2i').inspect 
     | 
| 
       383 
     | 
    
         
            -
              #     Complex(0, Float::INFINITY).inspect 
     | 
| 
       384 
     | 
    
         
            -
              #     Complex(Float::NAN, Float::NAN).inspect 
     | 
| 
      
 441 
     | 
    
         
            +
              #     Complex(2).inspect                      # => "(2+0i)"
         
     | 
| 
      
 442 
     | 
    
         
            +
              #     Complex('-8/6').inspect                 # => "((-4/3)+0i)"
         
     | 
| 
      
 443 
     | 
    
         
            +
              #     Complex('1/2i').inspect                 # => "(0+(1/2)*i)"
         
     | 
| 
      
 444 
     | 
    
         
            +
              #     Complex(0, Float::INFINITY).inspect     # => "(0+Infinity*i)"
         
     | 
| 
      
 445 
     | 
    
         
            +
              #     Complex(Float::NAN, Float::NAN).inspect # => "(NaN+NaN*i)"
         
     | 
| 
       385 
446 
     | 
    
         
             
              #
         
     | 
| 
       386 
447 
     | 
    
         
             
              def inspect: () -> String
         
     | 
| 
       387 
448 
     | 
    
         | 
| 
       388 
449 
     | 
    
         
             
              def integer?: () -> bool
         
     | 
| 
       389 
450 
     | 
    
         | 
| 
       390 
451 
     | 
    
         
             
              # <!-- rdoc-file=complex.c -->
         
     | 
| 
       391 
     | 
    
         
            -
              # Returns the absolute  
     | 
| 
      
 452 
     | 
    
         
            +
              # Returns the absolute value (magnitude) for `self`; see [polar
         
     | 
| 
      
 453 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Polar+Coordinates):
         
     | 
| 
      
 454 
     | 
    
         
            +
              #
         
     | 
| 
      
 455 
     | 
    
         
            +
              #     Complex.polar(-1, 0).abs # => 1.0
         
     | 
| 
       392 
456 
     | 
    
         
             
              #
         
     | 
| 
       393 
     | 
    
         
            -
              # 
     | 
| 
       394 
     | 
    
         
            -
              # 
     | 
| 
      
 457 
     | 
    
         
            +
              # If `self` was created with [rectangular
         
     | 
| 
      
 458 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is
         
     | 
| 
      
 459 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
      
 460 
     | 
    
         
            +
              #
         
     | 
| 
      
 461 
     | 
    
         
            +
              #     Complex.rectangular(1, 1).abs # => 1.4142135623730951 # The square root of 2.
         
     | 
| 
       395 
462 
     | 
    
         
             
              #
         
     | 
| 
       396 
463 
     | 
    
         
             
              alias magnitude abs
         
     | 
| 
       397 
464 
     | 
    
         | 
| 
         @@ -403,39 +470,54 @@ class Complex < Numeric 
     | 
|
| 
       403 
470 
     | 
    
         | 
| 
       404 
471 
     | 
    
         
             
              # <!--
         
     | 
| 
       405 
472 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       406 
     | 
    
         
            -
              #   -  
     | 
| 
      
 473 
     | 
    
         
            +
              #   - numerator -> new_complex
         
     | 
| 
       407 
474 
     | 
    
         
             
              # -->
         
     | 
| 
       408 
     | 
    
         
            -
              # Returns the  
     | 
| 
      
 475 
     | 
    
         
            +
              # Returns the Complex object created from the numerators of the real and
         
     | 
| 
      
 476 
     | 
    
         
            +
              # imaginary parts of `self`, after converting each part to the [lowest common
         
     | 
| 
      
 477 
     | 
    
         
            +
              # denominator](https://en.wikipedia.org/wiki/Lowest_common_denominator) of the
         
     | 
| 
      
 478 
     | 
    
         
            +
              # two:
         
     | 
| 
       409 
479 
     | 
    
         
             
              #
         
     | 
| 
       410 
     | 
    
         
            -
              # 
     | 
| 
       411 
     | 
    
         
            -
              # 
     | 
| 
       412 
     | 
    
         
            -
              #         2   3        6    <-  denominator
         
     | 
| 
      
 480 
     | 
    
         
            +
              #     c = Complex(Rational(2, 3), Rational(3, 4)) # => ((2/3)+(3/4)*i)
         
     | 
| 
      
 481 
     | 
    
         
            +
              #     c.numerator                                 # => (8+9i)
         
     | 
| 
       413 
482 
     | 
    
         
             
              #
         
     | 
| 
       414 
     | 
    
         
            -
              # 
     | 
| 
       415 
     | 
    
         
            -
              # 
     | 
| 
       416 
     | 
    
         
            -
              # 
     | 
| 
       417 
     | 
    
         
            -
              # 
     | 
| 
       418 
     | 
    
         
            -
              #     Complex(Rational(n.real, d), Rational(n.imag, d))
         
     | 
| 
       419 
     | 
    
         
            -
              #                              #=> ((1/2)+(2/3)*i)
         
     | 
| 
      
 483 
     | 
    
         
            +
              # In this example, the lowest common denominator of the two parts is 12; the two
         
     | 
| 
      
 484 
     | 
    
         
            +
              # converted parts may be thought of as Rational(8, 12) and Rational(9, 12),
         
     | 
| 
      
 485 
     | 
    
         
            +
              # whose numerators, respectively, are 8 and 9; so the returned value of
         
     | 
| 
      
 486 
     | 
    
         
            +
              # `c.numerator` is `Complex(8, 9)`.
         
     | 
| 
       420 
487 
     | 
    
         
             
              #
         
     | 
| 
       421 
     | 
    
         
            -
              #  
     | 
| 
      
 488 
     | 
    
         
            +
              # Related: Complex#denominator.
         
     | 
| 
       422 
489 
     | 
    
         
             
              #
         
     | 
| 
       423 
490 
     | 
    
         
             
              def numerator: () -> Complex
         
     | 
| 
       424 
491 
     | 
    
         | 
| 
       425 
492 
     | 
    
         
             
              # <!-- rdoc-file=complex.c -->
         
     | 
| 
       426 
     | 
    
         
            -
              # Returns the angle  
     | 
| 
      
 493 
     | 
    
         
            +
              # Returns the argument (angle) for `self` in radians; see [polar
         
     | 
| 
      
 494 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Polar+Coordinates):
         
     | 
| 
      
 495 
     | 
    
         
            +
              #
         
     | 
| 
      
 496 
     | 
    
         
            +
              #     Complex.polar(3, Math::PI/2).arg  # => 1.57079632679489660
         
     | 
| 
      
 497 
     | 
    
         
            +
              #
         
     | 
| 
      
 498 
     | 
    
         
            +
              # If `self` was created with [rectangular
         
     | 
| 
      
 499 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is
         
     | 
| 
      
 500 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
       427 
501 
     | 
    
         
             
              #
         
     | 
| 
       428 
     | 
    
         
            -
              #     Complex.polar( 
     | 
| 
      
 502 
     | 
    
         
            +
              #     Complex.polar(1, 1.0/3).arg # => 0.33333333333333326
         
     | 
| 
       429 
503 
     | 
    
         
             
              #
         
     | 
| 
       430 
504 
     | 
    
         
             
              alias phase angle
         
     | 
| 
       431 
505 
     | 
    
         | 
| 
       432 
506 
     | 
    
         
             
              # <!--
         
     | 
| 
       433 
507 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       434 
     | 
    
         
            -
              #   -  
     | 
| 
      
 508 
     | 
    
         
            +
              #   - polar -> array
         
     | 
| 
       435 
509 
     | 
    
         
             
              # -->
         
     | 
| 
       436 
     | 
    
         
            -
              # Returns  
     | 
| 
      
 510 
     | 
    
         
            +
              # Returns the array `[self.abs, self.arg]`:
         
     | 
| 
       437 
511 
     | 
    
         
             
              #
         
     | 
| 
       438 
     | 
    
         
            -
              #     Complex(1, 2).polar 
     | 
| 
      
 512 
     | 
    
         
            +
              #     Complex.polar(1, 2).polar # => [1.0, 2.0]
         
     | 
| 
      
 513 
     | 
    
         
            +
              #
         
     | 
| 
      
 514 
     | 
    
         
            +
              # See [Polar Coordinates](rdoc-ref:Complex@Polar+Coordinates).
         
     | 
| 
      
 515 
     | 
    
         
            +
              #
         
     | 
| 
      
 516 
     | 
    
         
            +
              # If `self` was created with [rectangular
         
     | 
| 
      
 517 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Rectangular+Coordinates), the returned value is
         
     | 
| 
      
 518 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
      
 519 
     | 
    
         
            +
              #
         
     | 
| 
      
 520 
     | 
    
         
            +
              #     Complex.rect(1, 1).polar # => [1.4142135623730951, 0.7853981633974483]
         
     | 
| 
       439 
521 
     | 
    
         
             
              #
         
     | 
| 
       440 
522 
     | 
    
         
             
              def polar: () -> [ Numeric, Float ]
         
     | 
| 
       441 
523 
     | 
    
         | 
| 
         @@ -443,51 +525,73 @@ class Complex < Numeric 
     | 
|
| 
       443 
525 
     | 
    
         | 
| 
       444 
526 
     | 
    
         
             
              # <!--
         
     | 
| 
       445 
527 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       446 
     | 
    
         
            -
              #   -  
     | 
| 
       447 
     | 
    
         
            -
              #   - cmp.quo(numeric)  ->  complex
         
     | 
| 
      
 528 
     | 
    
         
            +
              #   - complex / numeric -> new_complex
         
     | 
| 
       448 
529 
     | 
    
         
             
              # -->
         
     | 
| 
       449 
     | 
    
         
            -
              #  
     | 
| 
      
 530 
     | 
    
         
            +
              # Returns the quotient of `self` and `numeric`:
         
     | 
| 
       450 
531 
     | 
    
         
             
              #
         
     | 
| 
       451 
     | 
    
         
            -
              #     Complex(2, 3)  / Complex(2, 3) 
     | 
| 
       452 
     | 
    
         
            -
              #     Complex(900)   / Complex(1) 
     | 
| 
       453 
     | 
    
         
            -
              #     Complex(-2, 9) / Complex(-9, 2) 
     | 
| 
       454 
     | 
    
         
            -
              #     Complex(9, 8)  / 4 
     | 
| 
       455 
     | 
    
         
            -
              #     Complex(20, 9) / 9.8 
     | 
| 
      
 532 
     | 
    
         
            +
              #     Complex(2, 3)  / Complex(2, 3)  # => ((1/1)+(0/1)*i)
         
     | 
| 
      
 533 
     | 
    
         
            +
              #     Complex(900)   / Complex(1)     # => ((900/1)+(0/1)*i)
         
     | 
| 
      
 534 
     | 
    
         
            +
              #     Complex(-2, 9) / Complex(-9, 2) # => ((36/85)-(77/85)*i)
         
     | 
| 
      
 535 
     | 
    
         
            +
              #     Complex(9, 8)  / 4              # => ((9/4)+(2/1)*i)
         
     | 
| 
      
 536 
     | 
    
         
            +
              #     Complex(20, 9) / 9.8            # => (2.0408163265306123+0.9183673469387754i)
         
     | 
| 
       456 
537 
     | 
    
         
             
              #
         
     | 
| 
       457 
538 
     | 
    
         
             
              def quo: (Numeric) -> Complex
         
     | 
| 
       458 
539 
     | 
    
         | 
| 
       459 
540 
     | 
    
         
             
              # <!--
         
     | 
| 
       460 
541 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       461 
     | 
    
         
            -
              #   -  
     | 
| 
      
 542 
     | 
    
         
            +
              #   - rationalize(epsilon = nil) -> rational
         
     | 
| 
       462 
543 
     | 
    
         
             
              # -->
         
     | 
| 
       463 
     | 
    
         
            -
              # Returns  
     | 
| 
       464 
     | 
    
         
            -
              #  
     | 
| 
      
 544 
     | 
    
         
            +
              # Returns a Rational object whose value is exactly or approximately equivalent
         
     | 
| 
      
 545 
     | 
    
         
            +
              # to that of `self.real`.
         
     | 
| 
      
 546 
     | 
    
         
            +
              #
         
     | 
| 
      
 547 
     | 
    
         
            +
              # With no argument `epsilon` given, returns a Rational object whose value is
         
     | 
| 
      
 548 
     | 
    
         
            +
              # exactly equal to that of `self.real.rationalize`:
         
     | 
| 
      
 549 
     | 
    
         
            +
              #
         
     | 
| 
      
 550 
     | 
    
         
            +
              #     Complex(1, 0).rationalize              # => (1/1)
         
     | 
| 
      
 551 
     | 
    
         
            +
              #     Complex(1, Rational(0, 1)).rationalize # => (1/1)
         
     | 
| 
      
 552 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize        # => (314159/100000)
         
     | 
| 
       465 
553 
     | 
    
         
             
              #
         
     | 
| 
       466 
     | 
    
         
            -
              # 
     | 
| 
       467 
     | 
    
         
            -
              # 
     | 
| 
       468 
     | 
    
         
            -
              #     Complex(1, 2).rationalize      # RangeError
         
     | 
| 
      
 554 
     | 
    
         
            +
              # With argument `epsilon` given, returns a Rational object whose value is
         
     | 
| 
      
 555 
     | 
    
         
            +
              # exactly or approximately equal to that of `self.real` to the given precision:
         
     | 
| 
       469 
556 
     | 
    
         
             
              #
         
     | 
| 
       470 
     | 
    
         
            -
              #  
     | 
| 
      
 557 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.1)          # => (16/5)
         
     | 
| 
      
 558 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.01)         # => (22/7)
         
     | 
| 
      
 559 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.001)        # => (201/64)
         
     | 
| 
      
 560 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.0001)       # => (333/106)
         
     | 
| 
      
 561 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.00001)      # => (355/113)
         
     | 
| 
      
 562 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.000001)     # => (7433/2366)
         
     | 
| 
      
 563 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.0000001)    # => (9208/2931)
         
     | 
| 
      
 564 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.00000001)   # => (47460/15107)
         
     | 
| 
      
 565 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.000000001)  # => (76149/24239)
         
     | 
| 
      
 566 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.0000000001) # => (314159/100000)
         
     | 
| 
      
 567 
     | 
    
         
            +
              #     Complex(3.14159, 0).rationalize(0.0)          # => (3537115888337719/1125899906842624)
         
     | 
| 
      
 568 
     | 
    
         
            +
              #
         
     | 
| 
      
 569 
     | 
    
         
            +
              # Related: Complex#to_r.
         
     | 
| 
       471 
570 
     | 
    
         
             
              #
         
     | 
| 
       472 
571 
     | 
    
         
             
              def rationalize: (?Numeric eps) -> Rational
         
     | 
| 
       473 
572 
     | 
    
         | 
| 
       474 
573 
     | 
    
         
             
              # <!--
         
     | 
| 
       475 
574 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       476 
     | 
    
         
            -
              #   -  
     | 
| 
      
 575 
     | 
    
         
            +
              #   - real -> numeric
         
     | 
| 
       477 
576 
     | 
    
         
             
              # -->
         
     | 
| 
       478 
     | 
    
         
            -
              # Returns the real  
     | 
| 
      
 577 
     | 
    
         
            +
              # Returns the real value for `self`:
         
     | 
| 
       479 
578 
     | 
    
         
             
              #
         
     | 
| 
       480 
579 
     | 
    
         
             
              #     Complex(7).real      #=> 7
         
     | 
| 
       481 
580 
     | 
    
         
             
              #     Complex(9, -4).real  #=> 9
         
     | 
| 
       482 
581 
     | 
    
         
             
              #
         
     | 
| 
      
 582 
     | 
    
         
            +
              # If `self` was created with [polar
         
     | 
| 
      
 583 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is
         
     | 
| 
      
 584 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
      
 585 
     | 
    
         
            +
              #
         
     | 
| 
      
 586 
     | 
    
         
            +
              #     Complex.polar(1, Math::PI/4).real # => 0.7071067811865476 # Square root of 2.
         
     | 
| 
      
 587 
     | 
    
         
            +
              #
         
     | 
| 
       483 
588 
     | 
    
         
             
              def real: () -> Numeric
         
     | 
| 
       484 
589 
     | 
    
         | 
| 
       485 
590 
     | 
    
         
             
              # <!--
         
     | 
| 
       486 
591 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       487 
     | 
    
         
            -
              #   -  
     | 
| 
       488 
     | 
    
         
            -
              #   - Complex(1, 2).real?  ->  false
         
     | 
| 
      
 592 
     | 
    
         
            +
              #   - real? -> false
         
     | 
| 
       489 
593 
     | 
    
         
             
              # -->
         
     | 
| 
       490 
     | 
    
         
            -
              # Returns false 
     | 
| 
      
 594 
     | 
    
         
            +
              # Returns `false`; for compatibility with Numeric#real?.
         
     | 
| 
       491 
595 
     | 
    
         
             
              #
         
     | 
| 
       492 
596 
     | 
    
         
             
              def real?: () -> false
         
     | 
| 
       493 
597 
     | 
    
         | 
| 
         @@ -507,12 +611,21 @@ class Complex < Numeric 
     | 
|
| 
       507 
611 
     | 
    
         | 
| 
       508 
612 
     | 
    
         
             
              # <!--
         
     | 
| 
       509 
613 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       510 
     | 
    
         
            -
              #   -  
     | 
| 
       511 
     | 
    
         
            -
              #   - cmp.rectangular  ->  array
         
     | 
| 
      
 614 
     | 
    
         
            +
              #   - rect -> array
         
     | 
| 
       512 
615 
     | 
    
         
             
              # -->
         
     | 
| 
       513 
     | 
    
         
            -
              # Returns  
     | 
| 
      
 616 
     | 
    
         
            +
              # Returns the array `[self.real, self.imag]`:
         
     | 
| 
      
 617 
     | 
    
         
            +
              #
         
     | 
| 
      
 618 
     | 
    
         
            +
              #     Complex.rect(1, 2).rect # => [1, 2]
         
     | 
| 
      
 619 
     | 
    
         
            +
              #
         
     | 
| 
      
 620 
     | 
    
         
            +
              # See [Rectangular Coordinates](rdoc-ref:Complex@Rectangular+Coordinates).
         
     | 
| 
      
 621 
     | 
    
         
            +
              #
         
     | 
| 
      
 622 
     | 
    
         
            +
              # If `self` was created with [polar
         
     | 
| 
      
 623 
     | 
    
         
            +
              # coordinates](rdoc-ref:Complex@Polar+Coordinates), the returned value is
         
     | 
| 
      
 624 
     | 
    
         
            +
              # computed, and may be inexact:
         
     | 
| 
       514 
625 
     | 
    
         
             
              #
         
     | 
| 
       515 
     | 
    
         
            -
              #     Complex(1,  
     | 
| 
      
 626 
     | 
    
         
            +
              #     Complex.polar(1.0, 1.0).rect # => [0.5403023058681398, 0.8414709848078965]
         
     | 
| 
      
 627 
     | 
    
         
            +
              #
         
     | 
| 
      
 628 
     | 
    
         
            +
              # Complex#rectangular is an alias for Complex#rect.
         
     | 
| 
       516 
629 
     | 
    
         
             
              #
         
     | 
| 
       517 
630 
     | 
    
         
             
              alias rectangular rect
         
     | 
| 
       518 
631 
     | 
    
         | 
| 
         @@ -524,38 +637,37 @@ class Complex < Numeric 
     | 
|
| 
       524 
637 
     | 
    
         | 
| 
       525 
638 
     | 
    
         
             
              # <!--
         
     | 
| 
       526 
639 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       527 
     | 
    
         
            -
              #   -  
     | 
| 
      
 640 
     | 
    
         
            +
              #   - to_c -> self
         
     | 
| 
       528 
641 
     | 
    
         
             
              # -->
         
     | 
| 
       529 
     | 
    
         
            -
              # Returns self 
     | 
| 
       530 
     | 
    
         
            -
              #
         
     | 
| 
       531 
     | 
    
         
            -
              #     Complex(2).to_c      #=> (2+0i)
         
     | 
| 
       532 
     | 
    
         
            -
              #     Complex(-8, 6).to_c  #=> (-8+6i)
         
     | 
| 
      
 642 
     | 
    
         
            +
              # Returns `self`.
         
     | 
| 
       533 
643 
     | 
    
         
             
              #
         
     | 
| 
       534 
644 
     | 
    
         
             
              def to_c: () -> Complex
         
     | 
| 
       535 
645 
     | 
    
         | 
| 
       536 
646 
     | 
    
         
             
              # <!--
         
     | 
| 
       537 
647 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       538 
     | 
    
         
            -
              #   -  
     | 
| 
      
 648 
     | 
    
         
            +
              #   - to_f -> float
         
     | 
| 
       539 
649 
     | 
    
         
             
              # -->
         
     | 
| 
       540 
     | 
    
         
            -
              # Returns the value as a  
     | 
| 
       541 
     | 
    
         
            -
              # 
     | 
| 
      
 650 
     | 
    
         
            +
              # Returns the value of `self.real` as a Float, if possible:
         
     | 
| 
      
 651 
     | 
    
         
            +
              #
         
     | 
| 
      
 652 
     | 
    
         
            +
              #     Complex(1, 0).to_f              # => 1.0
         
     | 
| 
      
 653 
     | 
    
         
            +
              #     Complex(1, Rational(0, 1)).to_f # => 1.0
         
     | 
| 
       542 
654 
     | 
    
         
             
              #
         
     | 
| 
       543 
     | 
    
         
            -
              # 
     | 
| 
       544 
     | 
    
         
            -
              # 
     | 
| 
       545 
     | 
    
         
            -
              #     Complex(1, 2).to_f    # RangeError
         
     | 
| 
      
 655 
     | 
    
         
            +
              # Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or
         
     | 
| 
      
 656 
     | 
    
         
            +
              # `Rational(0, *n*)`).
         
     | 
| 
       546 
657 
     | 
    
         
             
              #
         
     | 
| 
       547 
658 
     | 
    
         
             
              def to_f: () -> Float
         
     | 
| 
       548 
659 
     | 
    
         | 
| 
       549 
660 
     | 
    
         
             
              # <!--
         
     | 
| 
       550 
661 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       551 
     | 
    
         
            -
              #   -  
     | 
| 
      
 662 
     | 
    
         
            +
              #   - to_i -> integer
         
     | 
| 
       552 
663 
     | 
    
         
             
              # -->
         
     | 
| 
       553 
     | 
    
         
            -
              # Returns the value as an  
     | 
| 
       554 
     | 
    
         
            -
              # exactly zero).
         
     | 
| 
      
 664 
     | 
    
         
            +
              # Returns the value of `self.real` as an Integer, if possible:
         
     | 
| 
       555 
665 
     | 
    
         
             
              #
         
     | 
| 
       556 
     | 
    
         
            -
              #     Complex(1, 0).to_i 
     | 
| 
       557 
     | 
    
         
            -
              #     Complex(1, 0 
     | 
| 
       558 
     | 
    
         
            -
              # 
     | 
| 
      
 666 
     | 
    
         
            +
              #     Complex(1, 0).to_i              # => 1
         
     | 
| 
      
 667 
     | 
    
         
            +
              #     Complex(1, Rational(0, 1)).to_i # => 1
         
     | 
| 
      
 668 
     | 
    
         
            +
              #
         
     | 
| 
      
 669 
     | 
    
         
            +
              # Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or
         
     | 
| 
      
 670 
     | 
    
         
            +
              # `Rational(0, *n*)`).
         
     | 
| 
       559 
671 
     | 
    
         
             
              #
         
     | 
| 
       560 
672 
     | 
    
         
             
              def to_i: () -> Integer
         
     | 
| 
       561 
673 
     | 
    
         | 
| 
         @@ -563,30 +675,31 @@ class Complex < Numeric 
     | 
|
| 
       563 
675 
     | 
    
         | 
| 
       564 
676 
     | 
    
         
             
              # <!--
         
     | 
| 
       565 
677 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       566 
     | 
    
         
            -
              #   -  
     | 
| 
      
 678 
     | 
    
         
            +
              #   - to_r -> rational
         
     | 
| 
       567 
679 
     | 
    
         
             
              # -->
         
     | 
| 
       568 
     | 
    
         
            -
              # Returns the value as a  
     | 
| 
       569 
     | 
    
         
            -
              # 
     | 
| 
      
 680 
     | 
    
         
            +
              # Returns the value of `self.real` as a Rational, if possible:
         
     | 
| 
      
 681 
     | 
    
         
            +
              #
         
     | 
| 
      
 682 
     | 
    
         
            +
              #     Complex(1, 0).to_r              # => (1/1)
         
     | 
| 
      
 683 
     | 
    
         
            +
              #     Complex(1, Rational(0, 1)).to_r # => (1/1)
         
     | 
| 
       570 
684 
     | 
    
         
             
              #
         
     | 
| 
       571 
     | 
    
         
            -
              # 
     | 
| 
       572 
     | 
    
         
            -
              # 
     | 
| 
       573 
     | 
    
         
            -
              #     Complex(1, 2).to_r    # RangeError
         
     | 
| 
      
 685 
     | 
    
         
            +
              # Raises RangeError if `self.imag` is not exactly zero (either `Integer(0)` or
         
     | 
| 
      
 686 
     | 
    
         
            +
              # `Rational(0, *n*)`).
         
     | 
| 
       574 
687 
     | 
    
         
             
              #
         
     | 
| 
       575 
     | 
    
         
            -
              #  
     | 
| 
      
 688 
     | 
    
         
            +
              # Related: Complex#rationalize.
         
     | 
| 
       576 
689 
     | 
    
         
             
              #
         
     | 
| 
       577 
690 
     | 
    
         
             
              def to_r: () -> Rational
         
     | 
| 
       578 
691 
     | 
    
         | 
| 
       579 
692 
     | 
    
         
             
              # <!--
         
     | 
| 
       580 
693 
     | 
    
         
             
              #   rdoc-file=complex.c
         
     | 
| 
       581 
     | 
    
         
            -
              #   -  
     | 
| 
      
 694 
     | 
    
         
            +
              #   - to_s -> string
         
     | 
| 
       582 
695 
     | 
    
         
             
              # -->
         
     | 
| 
       583 
     | 
    
         
            -
              # Returns  
     | 
| 
      
 696 
     | 
    
         
            +
              # Returns a string representation of `self`:
         
     | 
| 
       584 
697 
     | 
    
         
             
              #
         
     | 
| 
       585 
     | 
    
         
            -
              #     Complex(2).to_s 
     | 
| 
       586 
     | 
    
         
            -
              #     Complex('-8/6').to_s 
     | 
| 
       587 
     | 
    
         
            -
              #     Complex('1/2i').to_s 
     | 
| 
       588 
     | 
    
         
            -
              #     Complex(0, Float::INFINITY).to_s 
     | 
| 
       589 
     | 
    
         
            -
              #     Complex(Float::NAN, Float::NAN).to_s 
     | 
| 
      
 698 
     | 
    
         
            +
              #     Complex(2).to_s                      # => "2+0i"
         
     | 
| 
      
 699 
     | 
    
         
            +
              #     Complex('-8/6').to_s                 # => "-4/3+0i"
         
     | 
| 
      
 700 
     | 
    
         
            +
              #     Complex('1/2i').to_s                 # => "0+1/2i"
         
     | 
| 
      
 701 
     | 
    
         
            +
              #     Complex(0, Float::INFINITY).to_s     # => "0+Infinity*i"
         
     | 
| 
      
 702 
     | 
    
         
            +
              #     Complex(Float::NAN, Float::NAN).to_s # => "NaN+NaN*i"
         
     | 
| 
       590 
703 
     | 
    
         
             
              #
         
     | 
| 
       591 
704 
     | 
    
         
             
              def to_s: () -> String
         
     | 
| 
       592 
705 
     | 
    
         |