rbs 0.12.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +8 -4
  3. data/.gitignore +0 -1
  4. data/CHANGELOG.md +32 -0
  5. data/Gemfile +4 -0
  6. data/README.md +8 -2
  7. data/Rakefile +9 -2
  8. data/Steepfile +1 -1
  9. data/bin/annotate-with-rdoc +1 -1
  10. data/bin/setup +0 -2
  11. data/bin/test_runner.rb +15 -1
  12. data/{stdlib/builtin → core}/array.rbs +124 -120
  13. data/{stdlib/builtin → core}/basic_object.rbs +54 -54
  14. data/{stdlib/builtin → core}/binding.rbs +42 -42
  15. data/core/builtin.rbs +70 -0
  16. data/{stdlib/builtin → core}/class.rbs +33 -33
  17. data/{stdlib/builtin → core}/comparable.rbs +0 -0
  18. data/{stdlib/builtin → core}/complex.rbs +90 -90
  19. data/{stdlib/builtin → core}/constants.rbs +0 -0
  20. data/{stdlib/builtin → core}/data.rbs +0 -0
  21. data/{stdlib/builtin → core}/deprecated.rbs +0 -0
  22. data/{stdlib/builtin → core}/dir.rbs +0 -0
  23. data/{stdlib/builtin → core}/encoding.rbs +33 -33
  24. data/{stdlib/builtin → core}/enumerable.rbs +58 -52
  25. data/{stdlib/builtin → core}/enumerator.rbs +35 -35
  26. data/{stdlib/builtin → core}/errno.rbs +0 -0
  27. data/{stdlib/builtin → core}/errors.rbs +2 -2
  28. data/{stdlib/builtin → core}/exception.rbs +50 -50
  29. data/{stdlib/builtin → core}/false_class.rbs +6 -6
  30. data/{stdlib/builtin → core}/fiber.rbs +14 -14
  31. data/{stdlib/builtin → core}/fiber_error.rbs +1 -1
  32. data/{stdlib/builtin → core}/file.rbs +0 -0
  33. data/{stdlib/builtin → core}/file_test.rbs +0 -0
  34. data/{stdlib/builtin → core}/float.rbs +161 -161
  35. data/{stdlib/builtin → core}/gc.rbs +3 -3
  36. data/{stdlib/builtin → core}/hash.rbs +7 -7
  37. data/{stdlib/builtin → core}/integer.rbs +0 -0
  38. data/{stdlib/builtin → core}/io.rbs +88 -88
  39. data/{stdlib/builtin → core}/kernel.rbs +71 -153
  40. data/{stdlib/builtin → core}/marshal.rbs +0 -0
  41. data/{stdlib/builtin → core}/match_data.rbs +1 -1
  42. data/{stdlib/builtin → core}/math.rbs +0 -0
  43. data/{stdlib/builtin → core}/method.rbs +19 -19
  44. data/{stdlib/builtin → core}/module.rbs +13 -13
  45. data/{stdlib/builtin → core}/nil_class.rbs +20 -20
  46. data/{stdlib/builtin → core}/numeric.rbs +101 -101
  47. data/{stdlib/builtin → core}/object.rbs +173 -173
  48. data/{stdlib/builtin → core}/proc.rbs +91 -91
  49. data/{stdlib/builtin → core}/process.rbs +0 -0
  50. data/{stdlib/builtin → core}/random.rbs +1 -1
  51. data/{stdlib/builtin → core}/range.rbs +3 -5
  52. data/{stdlib/builtin → core}/rational.rbs +83 -83
  53. data/{stdlib/builtin → core}/rb_config.rbs +0 -0
  54. data/{stdlib/builtin → core}/regexp.rbs +0 -0
  55. data/{stdlib/builtin → core}/ruby_vm.rbs +0 -0
  56. data/{stdlib/builtin → core}/signal.rbs +7 -7
  57. data/{stdlib/builtin → core}/string.rbs +10 -10
  58. data/{stdlib/builtin → core}/string_io.rbs +8 -8
  59. data/{stdlib/builtin → core}/struct.rbs +1 -1
  60. data/{stdlib/builtin → core}/symbol.rbs +1 -1
  61. data/{stdlib/builtin → core}/thread.rbs +189 -189
  62. data/{stdlib/builtin → core}/thread_group.rbs +2 -2
  63. data/{stdlib/builtin → core}/time.rbs +0 -0
  64. data/{stdlib/builtin → core}/trace_point.rbs +0 -0
  65. data/{stdlib/builtin → core}/true_class.rbs +10 -10
  66. data/{stdlib/builtin → core}/unbound_method.rbs +0 -0
  67. data/{stdlib/builtin → core}/warning.rbs +1 -1
  68. data/docs/CONTRIBUTING.md +1 -0
  69. data/docs/repo.md +125 -0
  70. data/docs/syntax.md +50 -6
  71. data/goodcheck.yml +22 -5
  72. data/lib/rbs.rb +1 -0
  73. data/lib/rbs/ast/comment.rb +1 -1
  74. data/lib/rbs/cli.rb +117 -107
  75. data/lib/rbs/constant.rb +1 -1
  76. data/lib/rbs/constant_table.rb +9 -8
  77. data/lib/rbs/definition_builder.rb +6 -7
  78. data/lib/rbs/environment.rb +5 -1
  79. data/lib/rbs/environment_loader.rb +79 -105
  80. data/lib/rbs/namespace.rb +1 -1
  81. data/lib/rbs/parser.rb +3148 -0
  82. data/lib/rbs/parser.y +10 -3
  83. data/lib/rbs/prototype/rb.rb +38 -6
  84. data/lib/rbs/prototype/runtime.rb +17 -7
  85. data/lib/rbs/repository.rb +121 -0
  86. data/lib/rbs/test/hook.rb +2 -0
  87. data/lib/rbs/test/setup.rb +5 -3
  88. data/lib/rbs/test/setup_helper.rb +4 -4
  89. data/lib/rbs/test/tester.rb +4 -1
  90. data/lib/rbs/test/type_check.rb +12 -6
  91. data/lib/rbs/type_name.rb +3 -2
  92. data/lib/rbs/variance_calculator.rb +2 -2
  93. data/lib/rbs/vendorer.rb +38 -16
  94. data/lib/rbs/version.rb +1 -1
  95. data/lib/rbs/writer.rb +25 -15
  96. data/sig/cli.rbs +58 -0
  97. data/sig/constant.rbs +21 -0
  98. data/sig/constant_table.rbs +30 -0
  99. data/sig/declarations.rbs +2 -2
  100. data/sig/definition.rbs +2 -2
  101. data/sig/definition_builder.rbs +6 -5
  102. data/sig/environment_loader.rbs +100 -0
  103. data/sig/members.rbs +2 -2
  104. data/sig/method_types.rbs +1 -1
  105. data/sig/namespace.rbs +4 -4
  106. data/sig/parser.rbs +25 -0
  107. data/sig/polyfill.rbs +42 -0
  108. data/sig/rbs.rbs +8 -0
  109. data/sig/repository.rbs +79 -0
  110. data/sig/substitution.rbs +3 -3
  111. data/sig/typename.rbs +1 -1
  112. data/sig/types.rbs +1 -1
  113. data/sig/vendorer.rbs +44 -0
  114. data/sig/version.rbs +3 -0
  115. data/sig/writer.rbs +40 -0
  116. data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
  117. data/stdlib/base64/{base64.rbs → 0/base64.rbs} +1 -1
  118. data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +2 -2
  119. data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
  120. data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
  121. data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +2 -2
  122. data/stdlib/csv/{csv.rbs → 0/csv.rbs} +1 -1
  123. data/stdlib/date/{date.rbs → 0/date.rbs} +4 -4
  124. data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +1 -1
  125. data/stdlib/dbm/0/dbm.rbs +277 -0
  126. data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
  127. data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
  128. data/stdlib/find/{find.rbs → 0/find.rbs} +12 -12
  129. data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
  130. data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
  131. data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
  132. data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
  133. data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +1 -1
  134. data/stdlib/logger/{logger.rbs → 0/logger.rbs} +1 -1
  135. data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
  136. data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
  137. data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
  138. data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +41 -39
  139. data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
  140. data/stdlib/prime/{prime.rbs → 0/prime.rbs} +0 -0
  141. data/stdlib/pstore/0/pstore.rbs +287 -0
  142. data/stdlib/pty/{pty.rbs → 0/pty.rbs} +1 -1
  143. data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
  144. data/stdlib/set/{set.rbs → 0/set.rbs} +0 -0
  145. data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +12 -12
  146. data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
  147. data/stdlib/uri/{generic.rbs → 0/generic.rbs} +2 -2
  148. data/stdlib/uri/0/http.rbs +158 -0
  149. data/stdlib/uri/0/https.rbs +108 -0
  150. data/stdlib/uri/0/ldap.rbs +224 -0
  151. data/stdlib/uri/0/ldaps.rbs +108 -0
  152. data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
  153. data/steep/Gemfile.lock +13 -17
  154. metadata +105 -89
  155. data/stdlib/builtin/builtin.rbs +0 -42
@@ -0,0 +1,70 @@
1
+ interface _ToI
2
+ def to_i: -> Integer
3
+ end
4
+
5
+ interface _ToInt
6
+ def to_int: -> Integer
7
+ end
8
+
9
+ interface _ToS
10
+ def to_s: -> String
11
+ end
12
+
13
+ interface _ToStr
14
+ def to_str: () -> String
15
+ end
16
+
17
+ interface _ToHash[K, V]
18
+ def to_hash: () -> Hash[K, V]
19
+ end
20
+
21
+ interface _ToProc
22
+ def to_proc: () -> untyped
23
+ end
24
+
25
+ interface _ToPath
26
+ def to_path: () -> String
27
+ end
28
+
29
+ interface _Each[out A, out B]
30
+ def each: { (A) -> void } -> B
31
+ end
32
+
33
+ interface _Reader
34
+ def read: (?int length, ?string outbuf) -> String?
35
+ end
36
+
37
+ interface _Writer
38
+ # Writes the +data+ string. Returns the number of bytes written
39
+ def write: (*_ToS data) -> Integer
40
+ end
41
+
42
+ interface _Rewindable
43
+ # Positions the stream to the beginning of input, resetting `lineno` to zero.
44
+ #
45
+ def rewind: () -> Integer
46
+ end
47
+
48
+ interface _ToIO
49
+ def to_io: () -> IO
50
+ end
51
+
52
+ interface _Exception
53
+ def exception: () -> Exception
54
+ | (String arg0) -> Exception
55
+ end
56
+
57
+ type int = Integer | _ToInt
58
+ type real = Integer | Float | Rational
59
+
60
+ type string = String | _ToStr
61
+ type encoding = Encoding | string
62
+
63
+ type io = IO | _ToIO
64
+
65
+ # `boolish` is a type for documentation.
66
+ # It means the value of this type is only for testing a condition.
67
+ # Unlike `bool` type, it doesn't require the value is one of `true` or `false`.
68
+ # Any Ruby object can have `boolish` type.
69
+ #
70
+ type boolish = top
@@ -1,18 +1,18 @@
1
1
  # Extends any Class to include *json_creatable?* method.
2
2
  # Classes in Ruby are first-class objects---each is an instance of class Class.
3
- #
3
+ #
4
4
  # Typically, you create a new class by using:
5
- #
5
+ #
6
6
  # class Name
7
7
  # # some code describing the class behavior
8
8
  # end
9
- #
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
13
  # When `Name.new` is called to create a new object, the #new method in Class is
14
14
  # run by default. This can be demonstrated by overriding #new in Class:
15
- #
15
+ #
16
16
  # class Class
17
17
  # alias old_new new
18
18
  # def new(*args)
@@ -20,16 +20,16 @@
20
20
  # old_new(*args)
21
21
  # end
22
22
  # end
23
- #
23
+ #
24
24
  # class Name
25
25
  # end
26
- #
26
+ #
27
27
  # n = Name.new
28
- #
28
+ #
29
29
  # *produces:*
30
- #
30
+ #
31
31
  # Creating a new Name
32
- #
32
+ #
33
33
  # Classes, modules, and objects are interrelated. In the diagram that follows,
34
34
  # the vertical arrows represent inheritance, and the parentheses metaclasses.
35
35
  # All metaclasses are instances of the class `Class'.
@@ -51,15 +51,15 @@
51
51
  # | +---+ | +----+
52
52
  # | |
53
53
  # obj--->OtherClass---------->(OtherClass)-----------...
54
- #
54
+ #
55
55
  class Class < Module
56
56
  # Creates a new anonymous (unnamed) class with the given superclass (or Object
57
57
  # if no parameter is given). You can give a class a name by assigning the class
58
58
  # object to a constant.
59
- #
59
+ #
60
60
  # If a block is given, it is passed the class object, and the block is evaluated
61
61
  # in the context of this class like #class_eval.
62
- #
62
+ #
63
63
  # fred = Class.new do
64
64
  # def meth1
65
65
  # "hello"
@@ -68,78 +68,78 @@ class Class < Module
68
68
  # "bye"
69
69
  # end
70
70
  # end
71
- #
71
+ #
72
72
  # a = fred.new #=> #<#<Class:0x100381890>:0x100376b98>
73
73
  # a.meth1 #=> "hello"
74
74
  # a.meth2 #=> "bye"
75
- #
75
+ #
76
76
  # Assign the class to a constant (name starting uppercase) if you want to treat
77
77
  # it like a regular class.
78
- #
78
+ #
79
79
  def initialize: (?Class superclass) ?{ (Class newclass) -> void } -> void
80
80
 
81
81
  # Allocates space for a new object of *class*'s class and does not call
82
82
  # initialize on the new instance. The returned object must be an instance of
83
83
  # *class*.
84
- #
84
+ #
85
85
  # klass = Class.new do
86
86
  # def initialize(*args)
87
87
  # @initialized = true
88
88
  # end
89
- #
89
+ #
90
90
  # def initialized?
91
91
  # @initialized || false
92
92
  # end
93
93
  # end
94
- #
94
+ #
95
95
  # klass.allocate.initialized? #=> false
96
- #
96
+ #
97
97
  def allocate: () -> untyped
98
98
 
99
99
  # Callback invoked whenever a subclass of the current class is created.
100
- #
100
+ #
101
101
  # Example:
102
- #
102
+ #
103
103
  # class Foo
104
104
  # def self.inherited(subclass)
105
105
  # puts "New subclass: #{subclass}"
106
106
  # end
107
107
  # end
108
- #
108
+ #
109
109
  # class Bar < Foo
110
110
  # end
111
- #
111
+ #
112
112
  # class Baz < Bar
113
113
  # end
114
- #
114
+ #
115
115
  # *produces:*
116
- #
116
+ #
117
117
  # New subclass: Bar
118
118
  # New subclass: Baz
119
- #
119
+ #
120
120
  def inherited: (Class arg0) -> untyped
121
121
 
122
122
  # Calls #allocate to create a new object of *class*'s class, then invokes that
123
123
  # object's #initialize method, passing it *args*. This is the method that ends
124
124
  # up getting called whenever an object is constructed using `.new`.
125
- #
125
+ #
126
126
  def new: () -> untyped
127
127
 
128
128
  # Returns the superclass of *class*, or `nil`.
129
- #
129
+ #
130
130
  # File.superclass #=> IO
131
131
  # IO.superclass #=> Object
132
132
  # Object.superclass #=> BasicObject
133
133
  # class Foo; end
134
134
  # class Bar < Foo; end
135
135
  # Bar.superclass #=> Foo
136
- #
136
+ #
137
137
  # Returns nil when the given class does not have a parent class:
138
- #
138
+ #
139
139
  # BasicObject.superclass #=> nil
140
- #
140
+ #
141
141
  # # arglists
142
142
  # class.superclass -> a_super_class or nil
143
- #
143
+ #
144
144
  def `superclass`: () -> Class?
145
145
  end
File without changes
@@ -1,110 +1,110 @@
1
1
  # A complex number can be represented as a paired real number with imaginary
2
2
  # unit; a+bi. Where a is real part, b is imaginary part and i is imaginary
3
3
  # unit. Real a equals complex a+0i mathematically.
4
- #
4
+ #
5
5
  # Complex object can be created as literal, and also by using Kernel#Complex,
6
6
  # Complex::rect, Complex::polar or to_c method.
7
- #
7
+ #
8
8
  # 2+1i #=> (2+1i)
9
9
  # Complex(1) #=> (1+0i)
10
10
  # Complex(2, 3) #=> (2+3i)
11
11
  # Complex.polar(2, 3) #=> (-1.9799849932008908+0.2822400161197344i)
12
12
  # 3.to_c #=> (3+0i)
13
- #
13
+ #
14
14
  # You can also create complex object from floating-point numbers or strings.
15
- #
15
+ #
16
16
  # Complex(0.3) #=> (0.3+0i)
17
17
  # Complex('0.3-0.5i') #=> (0.3-0.5i)
18
18
  # Complex('2/3+3/4i') #=> ((2/3)+(3/4)*i)
19
19
  # Complex('1@2') #=> (-0.4161468365471424+0.9092974268256817i)
20
- #
20
+ #
21
21
  # 0.3.to_c #=> (0.3+0i)
22
22
  # '0.3-0.5i'.to_c #=> (0.3-0.5i)
23
23
  # '2/3+3/4i'.to_c #=> ((2/3)+(3/4)*i)
24
24
  # '1@2'.to_c #=> (-0.4161468365471424+0.9092974268256817i)
25
- #
25
+ #
26
26
  # A complex object is either an exact or an inexact number.
27
- #
27
+ #
28
28
  # Complex(1, 1) / 2 #=> ((1/2)+(1/2)*i)
29
29
  # Complex(1, 1) / 2.0 #=> (0.5+0.5i)
30
- #
30
+ #
31
31
  class Complex < Numeric
32
32
  # Returns a complex object which denotes the given polar form.
33
- #
33
+ #
34
34
  # Complex.polar(3, 0) #=> (3.0+0.0i)
35
35
  # Complex.polar(3, Math::PI/2) #=> (1.836909530733566e-16+3.0i)
36
36
  # Complex.polar(3, Math::PI) #=> (-3.0+3.673819061467132e-16i)
37
37
  # Complex.polar(3, -Math::PI/2) #=> (1.836909530733566e-16-3.0i)
38
- #
38
+ #
39
39
  def self.polar: (Numeric, ?Numeric) -> Complex
40
40
 
41
41
  # Returns a complex object which denotes the given rectangular form.
42
- #
42
+ #
43
43
  # Complex.rectangular(1, 2) #=> (1+2i)
44
- #
44
+ #
45
45
  def self.rect: (Numeric, ?Numeric) -> Complex
46
46
 
47
47
  # Returns a complex object which denotes the given rectangular form.
48
- #
48
+ #
49
49
  # Complex.rectangular(1, 2) #=> (1+2i)
50
- #
50
+ #
51
51
  alias self.rectangular self.rect
52
52
 
53
53
  public
54
54
 
55
55
  # Performs multiplication.
56
- #
56
+ #
57
57
  # Complex(2, 3) * Complex(2, 3) #=> (-5+12i)
58
58
  # Complex(900) * Complex(1) #=> (900+0i)
59
59
  # Complex(-2, 9) * Complex(-9, 2) #=> (0-85i)
60
60
  # Complex(9, 8) * 4 #=> (36+32i)
61
61
  # Complex(20, 9) * 9.8 #=> (196.0+88.2i)
62
- #
62
+ #
63
63
  def *: (Numeric) -> Complex
64
64
 
65
65
  # Performs exponentiation.
66
- #
66
+ #
67
67
  # Complex('i') ** 2 #=> (-1+0i)
68
68
  # Complex(-8) ** Rational(1, 3) #=> (1.0000000000000002+1.7320508075688772i)
69
- #
69
+ #
70
70
  def **: (Numeric) -> Complex
71
71
 
72
72
  # Performs addition.
73
- #
73
+ #
74
74
  # Complex(2, 3) + Complex(2, 3) #=> (4+6i)
75
75
  # Complex(900) + Complex(1) #=> (901+0i)
76
76
  # Complex(-2, 9) + Complex(-9, 2) #=> (-11+11i)
77
77
  # Complex(9, 8) + 4 #=> (13+8i)
78
78
  # Complex(20, 9) + 9.8 #=> (29.8+9i)
79
- #
79
+ #
80
80
  def +: (Numeric) -> Complex
81
81
 
82
82
  def +@: () -> Complex
83
83
 
84
84
  # Performs subtraction.
85
- #
85
+ #
86
86
  # Complex(2, 3) - Complex(2, 3) #=> (0+0i)
87
87
  # Complex(900) - Complex(1) #=> (899+0i)
88
88
  # Complex(-2, 9) - Complex(-9, 2) #=> (7+7i)
89
89
  # Complex(9, 8) - 4 #=> (5+8i)
90
90
  # Complex(20, 9) - 9.8 #=> (10.2+9i)
91
- #
91
+ #
92
92
  def -: (Numeric) -> Complex
93
93
 
94
94
  # Returns negation of the value.
95
- #
95
+ #
96
96
  # -Complex(1, 2) #=> (-1-2i)
97
- #
97
+ #
98
98
  def -@: () -> Complex
99
99
 
100
100
  # Performs division.
101
- #
101
+ #
102
102
  # Complex(2, 3) / Complex(2, 3) #=> ((1/1)+(0/1)*i)
103
103
  # Complex(900) / Complex(1) #=> ((900/1)+(0/1)*i)
104
104
  # Complex(-2, 9) / Complex(-9, 2) #=> ((36/85)-(77/85)*i)
105
105
  # Complex(9, 8) / 4 #=> ((9/4)+(2/1)*i)
106
106
  # Complex(20, 9) / 9.8 #=> (2.0408163265306123+0.9183673469387754i)
107
- #
107
+ #
108
108
  def /: (Numeric) -> Complex
109
109
 
110
110
  def <: (Numeric) -> bot
@@ -114,23 +114,23 @@ class Complex < Numeric
114
114
  # If `cmp`'s imaginary part is zero, and `object` is also a real number (or a
115
115
  # Complex number where the imaginary part is zero), compare the real part of
116
116
  # `cmp` to object. Otherwise, return nil.
117
- #
117
+ #
118
118
  # Complex(2, 3) <=> Complex(2, 3) #=> nil
119
119
  # Complex(2, 3) <=> 1 #=> nil
120
120
  # Complex(2) <=> 1 #=> 1
121
121
  # Complex(2) <=> 2 #=> 0
122
122
  # Complex(2) <=> 3 #=> -1
123
- #
123
+ #
124
124
  def <=>: (Numeric) -> Integer?
125
125
 
126
126
  # Returns true if cmp equals object numerically.
127
- #
127
+ #
128
128
  # Complex(2, 3) == Complex(2, 3) #=> true
129
129
  # Complex(5) == 5 #=> true
130
130
  # Complex(0) == 0.0 #=> true
131
131
  # Complex('1/3') == 0.33 #=> false
132
132
  # Complex('1/2') == '1/2' #=> false
133
- #
133
+ #
134
134
  def ==: (untyped) -> bool
135
135
 
136
136
  def >: (Numeric) -> bot
@@ -138,29 +138,29 @@ class Complex < Numeric
138
138
  def >=: (Numeric) -> bot
139
139
 
140
140
  # Returns the absolute part of its polar form.
141
- #
141
+ #
142
142
  # Complex(-1).abs #=> 1
143
143
  # Complex(3.0, -4.0).abs #=> 5.0
144
- #
144
+ #
145
145
  def abs: () -> Numeric
146
146
 
147
147
  # Returns square of the absolute value.
148
- #
148
+ #
149
149
  # Complex(-1).abs2 #=> 1
150
150
  # Complex(3.0, -4.0).abs2 #=> 25.0
151
- #
151
+ #
152
152
  def abs2: () -> Numeric
153
153
 
154
154
  # Returns the angle part of its polar form.
155
- #
155
+ #
156
156
  # Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966
157
- #
157
+ #
158
158
  def angle: () -> Float
159
159
 
160
160
  # Returns the angle part of its polar form.
161
- #
161
+ #
162
162
  # Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966
163
- #
163
+ #
164
164
  alias arg angle
165
165
 
166
166
  def ceil: (*untyped) -> bot
@@ -170,21 +170,21 @@ class Complex < Numeric
170
170
  def coerce: (Numeric) -> [ Complex, Complex ]
171
171
 
172
172
  # Returns the complex conjugate.
173
- #
173
+ #
174
174
  # Complex(1, 2).conjugate #=> (1-2i)
175
- #
175
+ #
176
176
  def conj: () -> Complex
177
177
 
178
178
  # Returns the complex conjugate.
179
- #
179
+ #
180
180
  # Complex(1, 2).conjugate #=> (1-2i)
181
- #
181
+ #
182
182
  def conjugate: () -> Complex
183
183
 
184
184
  # Returns the denominator (lcm of both denominator - real and imag).
185
- #
185
+ #
186
186
  # See numerator.
187
- #
187
+ #
188
188
  def denominator: () -> Integer
189
189
 
190
190
  def div: (Numeric) -> bot
@@ -196,14 +196,14 @@ class Complex < Numeric
196
196
  def eql?: (untyped) -> bool
197
197
 
198
198
  # Performs division as each part is a float, never returns a float.
199
- #
199
+ #
200
200
  # Complex(11, 22).fdiv(3) #=> (3.6666666666666665+7.333333333333333i)
201
- #
201
+ #
202
202
  def fdiv: (Numeric) -> Complex
203
203
 
204
204
  # Returns `true` if `cmp`'s real and imaginary parts are both finite numbers,
205
205
  # otherwise returns `false`.
206
- #
206
+ #
207
207
  def finite?: () -> bool
208
208
 
209
209
  def floor: (?Integer) -> bot
@@ -213,46 +213,46 @@ class Complex < Numeric
213
213
  def i: () -> bot
214
214
 
215
215
  # Returns the imaginary part.
216
- #
216
+ #
217
217
  # Complex(7).imaginary #=> 0
218
218
  # Complex(9, -4).imaginary #=> -4
219
- #
219
+ #
220
220
  def imag: () -> Numeric
221
221
 
222
222
  # Returns the imaginary part.
223
- #
223
+ #
224
224
  # Complex(7).imaginary #=> 0
225
225
  # Complex(9, -4).imaginary #=> -4
226
- #
226
+ #
227
227
  def imaginary: () -> Numeric
228
228
 
229
229
  # Returns `1` if `cmp`'s real or imaginary part is an infinite number, otherwise
230
230
  # returns `nil`.
231
- #
231
+ #
232
232
  # For example:
233
- #
233
+ #
234
234
  # (1+1i).infinite? #=> nil
235
235
  # (Float::INFINITY + 1i).infinite? #=> 1
236
- #
236
+ #
237
237
  def infinite?: () -> Integer?
238
238
 
239
239
  # Returns the value as a string for inspection.
240
- #
240
+ #
241
241
  # Complex(2).inspect #=> "(2+0i)"
242
242
  # Complex('-8/6').inspect #=> "((-4/3)+0i)"
243
243
  # Complex('1/2i').inspect #=> "(0+(1/2)*i)"
244
244
  # Complex(0, Float::INFINITY).inspect #=> "(0+Infinity*i)"
245
245
  # Complex(Float::NAN, Float::NAN).inspect #=> "(NaN+NaN*i)"
246
- #
246
+ #
247
247
  def inspect: () -> String
248
248
 
249
249
  def integer?: () -> bool
250
250
 
251
251
  # Returns the absolute part of its polar form.
252
- #
252
+ #
253
253
  # Complex(-1).abs #=> 1
254
254
  # Complex(3.0, -4.0).abs #=> 5.0
255
- #
255
+ #
256
256
  alias magnitude abs
257
257
 
258
258
  def modulo: (Numeric) -> bot
@@ -262,78 +262,78 @@ class Complex < Numeric
262
262
  def nonzero?: () -> self?
263
263
 
264
264
  # Returns the numerator.
265
- #
265
+ #
266
266
  # 1 2 3+4i <- numerator
267
267
  # - + -i -> ----
268
268
  # 2 3 6 <- denominator
269
- #
269
+ #
270
270
  # c = Complex('1/2+2/3i') #=> ((1/2)+(2/3)*i)
271
271
  # n = c.numerator #=> (3+4i)
272
272
  # d = c.denominator #=> 6
273
273
  # n / d #=> ((1/2)+(2/3)*i)
274
274
  # Complex(Rational(n.real, d), Rational(n.imag, d))
275
275
  # #=> ((1/2)+(2/3)*i)
276
- #
276
+ #
277
277
  # See denominator.
278
- #
278
+ #
279
279
  def numerator: () -> Complex
280
280
 
281
281
  # Returns the angle part of its polar form.
282
- #
282
+ #
283
283
  # Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966
284
- #
284
+ #
285
285
  alias phase angle
286
286
 
287
287
  # Returns an array; [cmp.abs, cmp.arg].
288
- #
288
+ #
289
289
  # Complex(1, 2).polar #=> [2.23606797749979, 1.1071487177940904]
290
- #
290
+ #
291
291
  def polar: () -> [Numeric, Float]
292
292
 
293
293
  def positive?: () -> bot
294
294
 
295
295
  # Performs division.
296
- #
296
+ #
297
297
  # Complex(2, 3) / Complex(2, 3) #=> ((1/1)+(0/1)*i)
298
298
  # Complex(900) / Complex(1) #=> ((900/1)+(0/1)*i)
299
299
  # Complex(-2, 9) / Complex(-9, 2) #=> ((36/85)-(77/85)*i)
300
300
  # Complex(9, 8) / 4 #=> ((9/4)+(2/1)*i)
301
301
  # Complex(20, 9) / 9.8 #=> (2.0408163265306123+0.9183673469387754i)
302
- #
302
+ #
303
303
  def quo: (Numeric) -> Complex
304
304
 
305
305
  # Returns the value as a rational if possible (the imaginary part should be
306
306
  # exactly zero).
307
- #
307
+ #
308
308
  # Complex(1.0/3, 0).rationalize #=> (1/3)
309
309
  # Complex(1, 0.0).rationalize # RangeError
310
310
  # Complex(1, 2).rationalize # RangeError
311
- #
311
+ #
312
312
  # See to_r.
313
- #
313
+ #
314
314
  def rationalize: (?Numeric eps) -> Rational
315
315
 
316
316
  # Returns the real part.
317
- #
317
+ #
318
318
  # Complex(7).real #=> 7
319
319
  # Complex(9, -4).real #=> 9
320
- #
320
+ #
321
321
  def real: () -> Numeric
322
322
 
323
323
  # Returns false, even if the complex number has no imaginary part.
324
- #
324
+ #
325
325
  def real?: () -> false
326
326
 
327
327
  # Returns an array; [cmp.real, cmp.imag].
328
- #
328
+ #
329
329
  # Complex(1, 2).rectangular #=> [1, 2]
330
- #
330
+ #
331
331
  def rect: () -> [Numeric, Numeric]
332
332
 
333
333
  # Returns an array; [cmp.real, cmp.imag].
334
- #
334
+ #
335
335
  # Complex(1, 2).rectangular #=> [1, 2]
336
- #
336
+ #
337
337
  alias rectangular rect
338
338
 
339
339
  def reminder: (Numeric) -> bot
@@ -343,51 +343,51 @@ class Complex < Numeric
343
343
  def step: (*untyped) ?{ (*untyped) -> untyped } -> bot
344
344
 
345
345
  # Returns self.
346
- #
346
+ #
347
347
  # Complex(2).to_c #=> (2+0i)
348
348
  # Complex(-8, 6).to_c #=> (-8+6i)
349
- #
349
+ #
350
350
  def to_c: () -> Complex
351
351
 
352
352
  # Returns the value as a float if possible (the imaginary part should be exactly
353
353
  # zero).
354
- #
354
+ #
355
355
  # Complex(1, 0).to_f #=> 1.0
356
356
  # Complex(1, 0.0).to_f # RangeError
357
357
  # Complex(1, 2).to_f # RangeError
358
- #
358
+ #
359
359
  def to_f: () -> Float
360
360
 
361
361
  # Returns the value as an integer if possible (the imaginary part should be
362
362
  # exactly zero).
363
- #
363
+ #
364
364
  # Complex(1, 0).to_i #=> 1
365
365
  # Complex(1, 0.0).to_i # RangeError
366
366
  # Complex(1, 2).to_i # RangeError
367
- #
367
+ #
368
368
  def to_i: () -> Integer
369
369
 
370
370
  alias to_int to_i
371
371
 
372
372
  # Returns the value as a rational if possible (the imaginary part should be
373
373
  # exactly zero).
374
- #
374
+ #
375
375
  # Complex(1, 0).to_r #=> (1/1)
376
376
  # Complex(1, 0.0).to_r # RangeError
377
377
  # Complex(1, 2).to_r # RangeError
378
- #
378
+ #
379
379
  # See rationalize.
380
- #
380
+ #
381
381
  def to_r: () -> Rational
382
382
 
383
383
  # Returns the value as a string.
384
- #
384
+ #
385
385
  # Complex(2).to_s #=> "2+0i"
386
386
  # Complex('-8/6').to_s #=> "-4/3+0i"
387
387
  # Complex('1/2i').to_s #=> "0+1/2i"
388
388
  # Complex(0, Float::INFINITY).to_s #=> "0+Infinity*i"
389
389
  # Complex(Float::NAN, Float::NAN).to_s #=> "NaN+NaN*i"
390
- #
390
+ #
391
391
  def to_s: () -> String
392
392
 
393
393
  def truncate: (?Integer) -> bot
@@ -396,5 +396,5 @@ class Complex < Numeric
396
396
  end
397
397
 
398
398
  # The imaginary unit.
399
- #
399
+ #
400
400
  Complex::I: Complex