rbs 0.13.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +9 -5
  3. data/.gitignore +0 -1
  4. data/CHANGELOG.md +33 -1
  5. data/Gemfile +4 -0
  6. data/README.md +9 -3
  7. data/Rakefile +14 -1
  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 +1 -1
  23. data/{stdlib/builtin → core}/encoding.rbs +33 -33
  24. data/{stdlib/builtin → core}/enumerable.rbs +99 -92
  25. data/{stdlib/builtin → core}/enumerator.rbs +40 -40
  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 +15 -15
  37. data/{stdlib/builtin → core}/integer.rbs +0 -0
  38. data/{stdlib/builtin → core}/io.rbs +89 -89
  39. data/{stdlib/builtin → core}/kernel.rbs +70 -154
  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 +4 -6
  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 +2 -2
  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 +105 -103
  75. data/lib/rbs/definition.rb +9 -4
  76. data/lib/rbs/definition_builder.rb +54 -22
  77. data/lib/rbs/environment.rb +1 -1
  78. data/lib/rbs/environment_loader.rb +79 -105
  79. data/lib/rbs/namespace.rb +1 -1
  80. data/lib/rbs/parser.rb +3153 -0
  81. data/lib/rbs/parser.y +25 -11
  82. data/lib/rbs/prototype/rb.rb +47 -9
  83. data/lib/rbs/prototype/runtime.rb +17 -7
  84. data/lib/rbs/repository.rb +121 -0
  85. data/lib/rbs/test/hook.rb +2 -0
  86. data/lib/rbs/test/setup.rb +5 -3
  87. data/lib/rbs/test/setup_helper.rb +4 -4
  88. data/lib/rbs/test/tester.rb +4 -1
  89. data/lib/rbs/test/type_check.rb +12 -6
  90. data/lib/rbs/type_name.rb +3 -2
  91. data/lib/rbs/variance_calculator.rb +1 -1
  92. data/lib/rbs/vendorer.rb +38 -16
  93. data/lib/rbs/version.rb +1 -1
  94. data/lib/rbs/writer.rb +1 -1
  95. data/sig/cli.rbs +58 -0
  96. data/sig/constant.rbs +2 -2
  97. data/sig/constant_table.rbs +11 -11
  98. data/sig/declarations.rbs +2 -2
  99. data/sig/definition.rbs +10 -5
  100. data/sig/definition_builder.rbs +4 -1
  101. data/sig/environment_loader.rbs +92 -46
  102. data/sig/members.rbs +2 -2
  103. data/sig/method_types.rbs +1 -1
  104. data/sig/namespace.rbs +4 -4
  105. data/sig/parser.rbs +25 -0
  106. data/sig/polyfill.rbs +42 -0
  107. data/sig/rbs.rbs +8 -0
  108. data/sig/repository.rbs +79 -0
  109. data/sig/substitution.rbs +3 -3
  110. data/sig/typename.rbs +1 -1
  111. data/sig/types.rbs +1 -1
  112. data/sig/vendorer.rbs +44 -0
  113. data/sig/writer.rbs +15 -15
  114. data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
  115. data/stdlib/base64/{base64.rbs → 0/base64.rbs} +1 -1
  116. data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +2 -2
  117. data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
  118. data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
  119. data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +2 -2
  120. data/stdlib/csv/{csv.rbs → 0/csv.rbs} +4 -4
  121. data/stdlib/date/{date.rbs → 0/date.rbs} +4 -4
  122. data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +1 -1
  123. data/stdlib/dbm/0/dbm.rbs +277 -0
  124. data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
  125. data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
  126. data/stdlib/find/{find.rbs → 0/find.rbs} +12 -12
  127. data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
  128. data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
  129. data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
  130. data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
  131. data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +1 -1
  132. data/stdlib/logger/{logger.rbs → 0/logger.rbs} +1 -1
  133. data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
  134. data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
  135. data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
  136. data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +40 -40
  137. data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
  138. data/stdlib/prime/{prime.rbs → 0/prime.rbs} +1 -1
  139. data/stdlib/pstore/0/pstore.rbs +287 -0
  140. data/stdlib/pty/{pty.rbs → 0/pty.rbs} +1 -1
  141. data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
  142. data/stdlib/set/{set.rbs → 0/set.rbs} +10 -10
  143. data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +12 -12
  144. data/stdlib/tsort/0/cyclic.rbs +4 -0
  145. data/stdlib/tsort/0/interfaces.rbs +19 -0
  146. data/stdlib/tsort/0/tsort.rbs +363 -0
  147. data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
  148. data/stdlib/uri/{generic.rbs → 0/generic.rbs} +1 -1
  149. data/stdlib/uri/{http.rbs → 0/http.rbs} +0 -0
  150. data/stdlib/uri/{https.rbs → 0/https.rbs} +0 -0
  151. data/stdlib/uri/{ldap.rbs → 0/ldap.rbs} +0 -0
  152. data/stdlib/uri/{ldaps.rbs → 0/ldaps.rbs} +0 -0
  153. data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
  154. data/steep/Gemfile.lock +9 -9
  155. metadata +104 -93
  156. data/stdlib/builtin/builtin.rbs +0 -42
File without changes
@@ -246,7 +246,7 @@ module Random::Formatter
246
246
  #
247
247
  # See RFC 3548 for the definition of URL-safe base64.
248
248
  #
249
- def urlsafe_base64: (?Integer? n, ?bool padding) -> String
249
+ def urlsafe_base64: (?Integer? n, ?boolish padding) -> String
250
250
 
251
251
  # SecureRandom.uuid generates a random v4 UUID (Universally Unique IDentifier).
252
252
  #
@@ -87,10 +87,8 @@
87
87
  # r.to_a #=> [xxx, xxxx, xxxxx, xxxxxx]
88
88
  # r.member?(Xs.new(5)) #=> true
89
89
  # ```
90
- class Range[Elem] < Object
91
- include Enumerable[Elem, Range[Elem]]
92
-
93
- def self.new: [U] (U from, U to, ?bool exclude_end) -> ::Range[U]
90
+ class Range[out Elem] < Object
91
+ include Enumerable[Elem]
94
92
 
95
93
  def ==: (untyped obj) -> bool
96
94
 
@@ -103,7 +101,7 @@ class Range[Elem] < Object
103
101
  # ```
104
102
  def begin: () -> Elem
105
103
 
106
- def bsearch: [U] () { (Elem arg0) -> bool } -> U?
104
+ def bsearch: [U] () { (Elem) -> boolish } -> U?
107
105
 
108
106
  def cover?: (untyped obj) -> bool
109
107
 
@@ -146,7 +144,7 @@ class Range[Elem] < Object
146
144
 
147
145
  def `include?`: (untyped obj) -> bool
148
146
 
149
- def initialize: (Elem _begin, Elem _end, ?bool exclude_end) -> void
147
+ def initialize: (Elem from, Elem to, ?boolish exclude_end) -> void
150
148
 
151
149
  # Convert this range object to a printable form (using `inspect` to
152
150
  # convert the begin and end objects).
@@ -1,43 +1,43 @@
1
1
  # A rational number can be represented as a pair of integer numbers: a/b (b>0),
2
2
  # where a is the numerator and b is the denominator. Integer a equals rational
3
3
  # a/1 mathematically.
4
- #
4
+ #
5
5
  # In Ruby, you can create rational objects with the Kernel#Rational, to_r, or
6
6
  # rationalize methods or by suffixing `r` to a literal. The return values will
7
7
  # be irreducible fractions.
8
- #
8
+ #
9
9
  # Rational(1) #=> (1/1)
10
10
  # Rational(2, 3) #=> (2/3)
11
11
  # Rational(4, -6) #=> (-2/3)
12
12
  # 3.to_r #=> (3/1)
13
13
  # 2/3r #=> (2/3)
14
- #
14
+ #
15
15
  # You can also create rational objects from floating-point numbers or strings.
16
- #
16
+ #
17
17
  # Rational(0.3) #=> (5404319552844595/18014398509481984)
18
18
  # Rational('0.3') #=> (3/10)
19
19
  # Rational('2/3') #=> (2/3)
20
- #
20
+ #
21
21
  # 0.3.to_r #=> (5404319552844595/18014398509481984)
22
22
  # '0.3'.to_r #=> (3/10)
23
23
  # '2/3'.to_r #=> (2/3)
24
24
  # 0.3.rationalize #=> (3/10)
25
- #
25
+ #
26
26
  # A rational object is an exact number, which helps you to write programs
27
27
  # without any rounding errors.
28
- #
28
+ #
29
29
  # 10.times.inject(0) {|t| t + 0.1 } #=> 0.9999999999999999
30
30
  # 10.times.inject(0) {|t| t + Rational('0.1') } #=> (1/1)
31
- #
31
+ #
32
32
  # However, when an expression includes an inexact component (numerical value or
33
33
  # operation), it will produce an inexact result.
34
- #
34
+ #
35
35
  # Rational(10) / 3 #=> (10/3)
36
36
  # Rational(10) / 3.0 #=> 3.3333333333333335
37
- #
37
+ #
38
38
  # Rational(-8) ** Rational(1, 3)
39
39
  # #=> (1.0000000000000002+1.7320508075688772i)
40
- #
40
+ #
41
41
  class Rational < Numeric
42
42
  public
43
43
 
@@ -47,37 +47,37 @@ class Rational < Numeric
47
47
  | (Numeric) -> Numeric
48
48
 
49
49
  # Performs multiplication.
50
- #
50
+ #
51
51
  # Rational(2, 3) * Rational(2, 3) #=> (4/9)
52
52
  # Rational(900) * Rational(1) #=> (900/1)
53
53
  # Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
54
54
  # Rational(9, 8) * 4 #=> (9/2)
55
55
  # Rational(20, 9) * 9.8 #=> 21.77777777777778
56
- #
56
+ #
57
57
  def *: (Float) -> Float
58
58
  | (Complex) -> Complex
59
59
  | (Numeric) -> Numeric
60
60
 
61
61
  # Performs exponentiation.
62
- #
62
+ #
63
63
  # Rational(2) ** Rational(3) #=> (8/1)
64
64
  # Rational(10) ** -2 #=> (1/100)
65
65
  # Rational(10) ** -2.0 #=> 0.01
66
66
  # Rational(-4) ** Rational(1, 2) #=> (0.0+2.0i)
67
67
  # Rational(1, 2) ** 0 #=> (1/1)
68
68
  # Rational(1, 2) ** 0.0 #=> 1.0
69
- #
69
+ #
70
70
  def **: (Complex) -> Complex
71
71
  | (Numeric) -> Numeric
72
72
 
73
73
  # Performs addition.
74
- #
74
+ #
75
75
  # Rational(2, 3) + Rational(2, 3) #=> (4/3)
76
76
  # Rational(900) + Rational(1) #=> (901/1)
77
77
  # Rational(-2, 9) + Rational(-9, 2) #=> (-85/18)
78
78
  # Rational(9, 8) + 4 #=> (41/8)
79
79
  # Rational(20, 9) + 9.8 #=> 12.022222222222222
80
- #
80
+ #
81
81
  def +: (Float) -> Float
82
82
  | (Complex) -> Complex
83
83
  | (Numeric) -> Rational
@@ -85,65 +85,65 @@ class Rational < Numeric
85
85
  def +@: () -> Rational
86
86
 
87
87
  # Performs subtraction.
88
- #
88
+ #
89
89
  # Rational(2, 3) - Rational(2, 3) #=> (0/1)
90
90
  # Rational(900) - Rational(1) #=> (899/1)
91
91
  # Rational(-2, 9) - Rational(-9, 2) #=> (77/18)
92
92
  # Rational(9, 8) - 4 #=> (-23/8)
93
93
  # Rational(20, 9) - 9.8 #=> -7.577777777777778
94
- #
94
+ #
95
95
  def -: (Float) -> Float
96
96
  | (Complex) -> Complex
97
97
  | (Numeric) -> Rational
98
98
 
99
99
  # Negates `rat`.
100
- #
100
+ #
101
101
  def -@: () -> Rational
102
102
 
103
103
  # Performs division.
104
- #
104
+ #
105
105
  # Rational(2, 3) / Rational(2, 3) #=> (1/1)
106
106
  # Rational(900) / Rational(1) #=> (900/1)
107
107
  # Rational(-2, 9) / Rational(-9, 2) #=> (4/81)
108
108
  # Rational(9, 8) / 4 #=> (9/32)
109
109
  # Rational(20, 9) / 9.8 #=> 0.22675736961451246
110
- #
110
+ #
111
111
  def /: (Float) -> Float
112
112
  | (Complex) -> Complex
113
113
  | (Numeric) -> Rational
114
114
 
115
115
  # Returns -1, 0, or +1 depending on whether `rational` is less than, equal to,
116
116
  # or greater than `numeric`.
117
- #
117
+ #
118
118
  # `nil` is returned if the two values are incomparable.
119
- #
119
+ #
120
120
  # Rational(2, 3) <=> Rational(2, 3) #=> 0
121
121
  # Rational(5) <=> 5 #=> 0
122
122
  # Rational(2, 3) <=> Rational(1, 3) #=> 1
123
123
  # Rational(1, 3) <=> 1 #=> -1
124
124
  # Rational(1, 3) <=> 0.3 #=> 1
125
- #
125
+ #
126
126
  # Rational(1, 3) <=> "0.3" #=> nil
127
- #
127
+ #
128
128
  def <=>: (Numeric) -> Integer?
129
129
 
130
130
  # Returns `true` if `rat` equals `object` numerically.
131
- #
131
+ #
132
132
  # Rational(2, 3) == Rational(2, 3) #=> true
133
133
  # Rational(5) == 5 #=> true
134
134
  # Rational(0) == 0.0 #=> true
135
135
  # Rational('1/3') == 0.33 #=> false
136
136
  # Rational('1/2') == '1/2' #=> false
137
- #
137
+ #
138
138
  def ==: (untyped) -> bool
139
139
 
140
140
  # Returns the absolute value of `rat`.
141
- #
141
+ #
142
142
  # (1/2r).abs #=> (1/2)
143
143
  # (-1/2r).abs #=> (1/2)
144
- #
144
+ #
145
145
  # Rational#magnitude is an alias for Rational#abs.
146
- #
146
+ #
147
147
  def abs: () -> Rational
148
148
 
149
149
  def abs2: () -> Rational
@@ -154,23 +154,23 @@ class Rational < Numeric
154
154
 
155
155
  # Returns the smallest number greater than or equal to `rat` with a precision of
156
156
  # `ndigits` decimal digits (default: 0).
157
- #
157
+ #
158
158
  # When the precision is negative, the returned value is an integer with at least
159
159
  # `ndigits.abs` trailing zeros.
160
- #
160
+ #
161
161
  # Returns a rational when `ndigits` is positive, otherwise returns an integer.
162
- #
162
+ #
163
163
  # Rational(3).ceil #=> 3
164
164
  # Rational(2, 3).ceil #=> 1
165
165
  # Rational(-3, 2).ceil #=> -1
166
- #
166
+ #
167
167
  # # decimal - 1 2 3 . 4 5 6
168
168
  # # ^ ^ ^ ^ ^ ^
169
169
  # # precision -3 -2 -1 0 +1 +2
170
- #
170
+ #
171
171
  # Rational('-123.456').ceil(+1).to_f #=> -123.4
172
172
  # Rational('-123.456').ceil(-1) #=> -120
173
- #
173
+ #
174
174
  def ceil: () -> Integer
175
175
  | (Integer digits) -> (Integer | Rational)
176
176
 
@@ -183,12 +183,12 @@ class Rational < Numeric
183
183
  def conjugate: () -> Rational
184
184
 
185
185
  # Returns the denominator (always positive).
186
- #
186
+ #
187
187
  # Rational(7).denominator #=> 1
188
188
  # Rational(7, 1).denominator #=> 1
189
189
  # Rational(9, -4).denominator #=> 4
190
190
  # Rational(-2, -10).denominator #=> 5
191
- #
191
+ #
192
192
  def denominator: () -> Integer
193
193
 
194
194
  def div: (Numeric) -> Integer
@@ -200,34 +200,34 @@ class Rational < Numeric
200
200
  def eql?: (untyped) -> bool
201
201
 
202
202
  # Performs division and returns the value as a Float.
203
- #
203
+ #
204
204
  # Rational(2, 3).fdiv(1) #=> 0.6666666666666666
205
205
  # Rational(2, 3).fdiv(0.5) #=> 1.3333333333333333
206
206
  # Rational(2).fdiv(3) #=> 0.6666666666666666
207
- #
207
+ #
208
208
  def fdiv: (Numeric) -> Float
209
209
 
210
210
  def finite?: () -> bool
211
211
 
212
212
  # Returns the largest number less than or equal to `rat` with a precision of
213
213
  # `ndigits` decimal digits (default: 0).
214
- #
214
+ #
215
215
  # When the precision is negative, the returned value is an integer with at least
216
216
  # `ndigits.abs` trailing zeros.
217
- #
217
+ #
218
218
  # Returns a rational when `ndigits` is positive, otherwise returns an integer.
219
- #
219
+ #
220
220
  # Rational(3).floor #=> 3
221
221
  # Rational(2, 3).floor #=> 0
222
222
  # Rational(-3, 2).floor #=> -2
223
- #
223
+ #
224
224
  # # decimal - 1 2 3 . 4 5 6
225
225
  # # ^ ^ ^ ^ ^ ^
226
226
  # # precision -3 -2 -1 0 +1 +2
227
- #
227
+ #
228
228
  # Rational('-123.456').floor(+1).to_f #=> -123.5
229
229
  # Rational('-123.456').floor(-1) #=> -130
230
- #
230
+ #
231
231
  def floor: () -> Integer
232
232
  | (Integer digits) -> (Integer | Rational)
233
233
 
@@ -242,40 +242,40 @@ class Rational < Numeric
242
242
  def infinite?: () -> Integer?
243
243
 
244
244
  # Returns the value as a string for inspection.
245
- #
245
+ #
246
246
  # Rational(2).inspect #=> "(2/1)"
247
247
  # Rational(-8, 6).inspect #=> "(-4/3)"
248
248
  # Rational('1/2').inspect #=> "(1/2)"
249
- #
249
+ #
250
250
  def inspect: () -> String
251
251
 
252
252
  def integer?: () -> bool
253
253
 
254
254
  # Returns the absolute value of `rat`.
255
- #
255
+ #
256
256
  # (1/2r).abs #=> (1/2)
257
257
  # (-1/2r).abs #=> (1/2)
258
- #
258
+ #
259
259
  # Rational#magnitude is an alias for Rational#abs.
260
- #
260
+ #
261
261
  alias magnitude abs
262
262
 
263
263
  def modulo: (Float) -> Float
264
264
  | (Numeric) -> Rational
265
265
 
266
266
  # Returns `true` if `rat` is less than 0.
267
- #
267
+ #
268
268
  def negative?: () -> bool
269
269
 
270
270
  def nonzero?: () -> self?
271
271
 
272
272
  # Returns the numerator.
273
- #
273
+ #
274
274
  # Rational(7).numerator #=> 7
275
275
  # Rational(7, 1).numerator #=> 7
276
276
  # Rational(9, -4).numerator #=> -9
277
277
  # Rational(-2, -10).numerator #=> 1
278
- #
278
+ #
279
279
  def numerator: () -> Integer
280
280
 
281
281
  alias phase angle
@@ -283,29 +283,29 @@ class Rational < Numeric
283
283
  def polar: () -> [ Rational, Integer | Float ]
284
284
 
285
285
  # Returns `true` if `rat` is greater than 0.
286
- #
286
+ #
287
287
  def positive?: () -> bool
288
288
 
289
289
  # Performs division.
290
- #
290
+ #
291
291
  # Rational(2, 3) / Rational(2, 3) #=> (1/1)
292
292
  # Rational(900) / Rational(1) #=> (900/1)
293
293
  # Rational(-2, 9) / Rational(-9, 2) #=> (4/81)
294
294
  # Rational(9, 8) / 4 #=> (9/32)
295
295
  # Rational(20, 9) / 9.8 #=> 0.22675736961451246
296
- #
296
+ #
297
297
  def quo: (Float) -> Float
298
298
  | (Complex) -> Complex
299
299
  | (Numeric) -> Rational
300
300
 
301
301
  # Returns a simpler approximation of the value if the optional argument `eps` is
302
302
  # given (rat-|eps| <= result <= rat+|eps|), self otherwise.
303
- #
303
+ #
304
304
  # r = Rational(5033165, 16777216)
305
305
  # r.rationalize #=> (5033165/16777216)
306
306
  # r.rationalize(Rational('0.01')) #=> (3/10)
307
307
  # r.rationalize(Rational('0.1')) #=> (1/3)
308
- #
308
+ #
309
309
  def rationalize: (?Numeric eps) -> Rational
310
310
 
311
311
  def real: () -> Rational
@@ -321,25 +321,25 @@ class Rational < Numeric
321
321
 
322
322
  # Returns `rat` rounded to the nearest value with a precision of `ndigits`
323
323
  # decimal digits (default: 0).
324
- #
324
+ #
325
325
  # When the precision is negative, the returned value is an integer with at least
326
326
  # `ndigits.abs` trailing zeros.
327
- #
327
+ #
328
328
  # Returns a rational when `ndigits` is positive, otherwise returns an integer.
329
- #
329
+ #
330
330
  # Rational(3).round #=> 3
331
331
  # Rational(2, 3).round #=> 1
332
332
  # Rational(-3, 2).round #=> -2
333
- #
333
+ #
334
334
  # # decimal - 1 2 3 . 4 5 6
335
335
  # # ^ ^ ^ ^ ^ ^
336
336
  # # precision -3 -2 -1 0 +1 +2
337
- #
337
+ #
338
338
  # Rational('-123.456').round(+1).to_f #=> -123.5
339
339
  # Rational('-123.456').round(-1) #=> -120
340
- #
340
+ #
341
341
  # The optional `half` keyword argument is available similar to Float#round.
342
- #
342
+ #
343
343
  # Rational(25, 100).round(1, half: :up) #=> (3/10)
344
344
  # Rational(25, 100).round(1, half: :down) #=> (1/5)
345
345
  # Rational(25, 100).round(1, half: :even) #=> (1/5)
@@ -349,7 +349,7 @@ class Rational < Numeric
349
349
  # Rational(-25, 100).round(1, half: :up) #=> (-3/10)
350
350
  # Rational(-25, 100).round(1, half: :down) #=> (-1/5)
351
351
  # Rational(-25, 100).round(1, half: :even) #=> (-1/5)
352
- #
352
+ #
353
353
  def round: (?half: :up | :down | :even) -> Integer
354
354
  | (Integer digits, ?half: :up | :down | :even) -> (Integer | Rational)
355
355
 
@@ -361,62 +361,62 @@ class Rational < Numeric
361
361
  def to_c: () -> Complex
362
362
 
363
363
  # Returns the value as a Float.
364
- #
364
+ #
365
365
  # Rational(2).to_f #=> 2.0
366
366
  # Rational(9, 4).to_f #=> 2.25
367
367
  # Rational(-3, 4).to_f #=> -0.75
368
368
  # Rational(20, 3).to_f #=> 6.666666666666667
369
- #
369
+ #
370
370
  def to_f: () -> Float
371
371
 
372
372
  # Returns the truncated value as an integer.
373
- #
373
+ #
374
374
  # Equivalent to Rational#truncate.
375
- #
375
+ #
376
376
  # Rational(2, 3).to_i #=> 0
377
377
  # Rational(3).to_i #=> 3
378
378
  # Rational(300.6).to_i #=> 300
379
379
  # Rational(98, 71).to_i #=> 1
380
380
  # Rational(-31, 2).to_i #=> -15
381
- #
381
+ #
382
382
  def to_i: () -> Integer
383
383
 
384
384
  alias to_int to_i
385
385
 
386
386
  # Returns self.
387
- #
387
+ #
388
388
  # Rational(2).to_r #=> (2/1)
389
389
  # Rational(-8, 6).to_r #=> (-4/3)
390
- #
390
+ #
391
391
  def to_r: () -> Rational
392
392
 
393
393
  # Returns the value as a string.
394
- #
394
+ #
395
395
  # Rational(2).to_s #=> "2/1"
396
396
  # Rational(-8, 6).to_s #=> "-4/3"
397
397
  # Rational('1/2').to_s #=> "1/2"
398
- #
398
+ #
399
399
  def to_s: () -> String
400
400
 
401
401
  # Returns `rat` truncated (toward zero) to a precision of `ndigits` decimal
402
402
  # digits (default: 0).
403
- #
403
+ #
404
404
  # When the precision is negative, the returned value is an integer with at least
405
405
  # `ndigits.abs` trailing zeros.
406
- #
406
+ #
407
407
  # Returns a rational when `ndigits` is positive, otherwise returns an integer.
408
- #
408
+ #
409
409
  # Rational(3).truncate #=> 3
410
410
  # Rational(2, 3).truncate #=> 0
411
411
  # Rational(-3, 2).truncate #=> -1
412
- #
412
+ #
413
413
  # # decimal - 1 2 3 . 4 5 6
414
414
  # # ^ ^ ^ ^ ^ ^
415
415
  # # precision -3 -2 -1 0 +1 +2
416
- #
416
+ #
417
417
  # Rational('-123.456').truncate(+1).to_f #=> -123.4
418
418
  # Rational('-123.456').truncate(-1) #=> -120
419
- #
419
+ #
420
420
  def truncate: () -> Integer
421
421
  | (Integer ndigits) -> (Integer | Rational)
422
422