rbs 3.1.3 → 3.2.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +0 -6
  3. data/CHANGELOG.md +68 -0
  4. data/Gemfile +0 -6
  5. data/Gemfile.lock +12 -21
  6. data/README.md +1 -1
  7. data/Rakefile +44 -0
  8. data/Steepfile +3 -3
  9. data/core/array.rbs +0 -8
  10. data/core/builtin.rbs +28 -8
  11. data/core/constants.rbs +13 -5
  12. data/core/exception.rbs +1 -1
  13. data/core/global_variables.rbs +27 -27
  14. data/core/io.rbs +163 -172
  15. data/core/kernel.rbs +7 -4
  16. data/core/module.rbs +34 -32
  17. data/core/object.rbs +2 -2
  18. data/core/string_io.rbs +9 -0
  19. data/core/thread.rbs +25 -1
  20. data/core/time.rbs +3 -3
  21. data/docs/CONTRIBUTING.md +1 -1
  22. data/docs/rbs_by_example.md +16 -35
  23. data/docs/repo.md +1 -1
  24. data/docs/sigs.md +7 -7
  25. data/docs/stdlib.md +2 -3
  26. data/docs/syntax.md +40 -40
  27. data/lib/rbs/cli.rb +15 -4
  28. data/lib/rbs/collection/installer.rb +5 -2
  29. data/lib/rbs/collection/sources/stdlib.rb +5 -1
  30. data/lib/rbs/errors.rb +8 -1
  31. data/lib/rbs/file_finder.rb +1 -1
  32. data/lib/rbs/prototype/rb.rb +64 -6
  33. data/lib/rbs/prototype/rbi.rb +2 -6
  34. data/lib/rbs/prototype/runtime.rb +29 -8
  35. data/lib/rbs/subtractor.rb +17 -0
  36. data/lib/rbs/type_name.rb +4 -4
  37. data/lib/rbs/version.rb +1 -1
  38. data/rbs.gemspec +1 -1
  39. data/schema/decls.json +1 -1
  40. data/sig/errors.rbs +54 -0
  41. data/sig/parser.rbs +2 -2
  42. data/sig/prototype/rb.rbs +9 -1
  43. data/sig/subtractor.rbs +4 -0
  44. data/stdlib/logger/0/logger.rbs +1 -1
  45. data/stdlib/observable/0/observable.rbs +219 -0
  46. data/stdlib/uri/0/common.rbs +24 -0
  47. data/stdlib/zlib/0/buf_error.rbs +79 -0
  48. data/stdlib/zlib/0/data_error.rbs +79 -0
  49. data/stdlib/zlib/0/deflate.rbs +276 -0
  50. data/stdlib/zlib/0/error.rbs +89 -0
  51. data/stdlib/zlib/0/gzip_file/crc_error.rbs +115 -0
  52. data/stdlib/zlib/0/gzip_file/error.rbs +128 -0
  53. data/stdlib/zlib/0/gzip_file/length_error.rbs +115 -0
  54. data/stdlib/zlib/0/gzip_file/no_footer.rbs +114 -0
  55. data/stdlib/zlib/0/gzip_file.rbs +228 -0
  56. data/stdlib/zlib/0/gzip_reader.rbs +362 -0
  57. data/stdlib/zlib/0/gzip_writer.rbs +237 -0
  58. data/stdlib/zlib/0/inflate.rbs +249 -0
  59. data/stdlib/zlib/0/mem_error.rbs +79 -0
  60. data/stdlib/zlib/0/need_dict.rbs +82 -0
  61. data/stdlib/zlib/0/stream_end.rbs +80 -0
  62. data/stdlib/zlib/0/stream_error.rbs +80 -0
  63. data/stdlib/zlib/0/version_error.rbs +80 -0
  64. data/stdlib/zlib/0/zstream.rbs +270 -0
  65. metadata +24 -8
  66. data/stdlib/prime/0/integer-extension.rbs +0 -41
  67. data/stdlib/prime/0/manifest.yaml +0 -2
  68. data/stdlib/prime/0/prime.rbs +0 -372
@@ -1,372 +0,0 @@
1
- # <!-- rdoc-file=lib/prime.rb -->
2
- # The set of all prime numbers.
3
- #
4
- # ## Example
5
- #
6
- # Prime.each(100) do |prime|
7
- # p prime #=> 2, 3, 5, 7, 11, ...., 97
8
- # end
9
- #
10
- # Prime is Enumerable:
11
- #
12
- # Prime.first 5 # => [2, 3, 5, 7, 11]
13
- #
14
- # ## Retrieving the instance
15
- #
16
- # For convenience, each instance method of `Prime`.instance can be accessed as a
17
- # class method of `Prime`.
18
- #
19
- # e.g.
20
- # Prime.instance.prime?(2) #=> true
21
- # Prime.prime?(2) #=> true
22
- #
23
- # ## Generators
24
- #
25
- # A "generator" provides an implementation of enumerating pseudo-prime numbers
26
- # and it remembers the position of enumeration and upper bound. Furthermore, it
27
- # is an external iterator of prime enumeration which is compatible with an
28
- # Enumerator.
29
- #
30
- # `Prime`::`PseudoPrimeGenerator` is the base class for generators. There are
31
- # few implementations of generator.
32
- #
33
- # `Prime`::`EratosthenesGenerator`
34
- # : Uses Eratosthenes' sieve.
35
- # `Prime`::`TrialDivisionGenerator`
36
- # : Uses the trial division method.
37
- # `Prime`::`Generator23`
38
- # : Generates all positive integers which are not divisible by either 2 or 3.
39
- # This sequence is very bad as a pseudo-prime sequence. But this is faster
40
- # and uses much less memory than the other generators. So, it is suitable
41
- # for factorizing an integer which is not large but has many prime factors.
42
- # e.g. for Prime#prime? .
43
- #
44
- class Prime
45
- include Singleton
46
-
47
- include Enumerable[Integer]
48
-
49
- extend Enumerable[Integer]
50
-
51
- # <!--
52
- # rdoc-file=lib/prime.rb
53
- # - each(ubound = nil, generator = EratosthenesGenerator.new, &block)
54
- # -->
55
- # Iterates the given block over all prime numbers.
56
- #
57
- # ## Parameters
58
- #
59
- # `ubound`
60
- # : Optional. An arbitrary positive number. The upper bound of enumeration.
61
- # The method enumerates prime numbers infinitely if `ubound` is nil.
62
- # `generator`
63
- # : Optional. An implementation of pseudo-prime generator.
64
- #
65
- #
66
- # ## Return value
67
- #
68
- # An evaluated value of the given block at the last time. Or an enumerator which
69
- # is compatible to an `Enumerator` if no block given.
70
- #
71
- # ## Description
72
- #
73
- # Calls `block` once for each prime number, passing the prime as a parameter.
74
- #
75
- # `ubound`
76
- # : Upper bound of prime numbers. The iterator stops after it yields all prime
77
- # numbers p <= `ubound`.
78
- #
79
- def self.each: (?Integer? ubound, ?PseudoPrimeGenerator generator) { (Integer) -> void } -> void
80
- | (?Integer? ubound, ?PseudoPrimeGenerator generator) -> PseudoPrimeGenerator
81
-
82
- # <!--
83
- # rdoc-file=lib/prime.rb
84
- # - each(ubound = nil, generator = EratosthenesGenerator.new, &block)
85
- # -->
86
- # Iterates the given block over all prime numbers.
87
- #
88
- # ## Parameters
89
- #
90
- # `ubound`
91
- # : Optional. An arbitrary positive number. The upper bound of enumeration.
92
- # The method enumerates prime numbers infinitely if `ubound` is nil.
93
- # `generator`
94
- # : Optional. An implementation of pseudo-prime generator.
95
- #
96
- #
97
- # ## Return value
98
- #
99
- # An evaluated value of the given block at the last time. Or an enumerator which
100
- # is compatible to an `Enumerator` if no block given.
101
- #
102
- # ## Description
103
- #
104
- # Calls `block` once for each prime number, passing the prime as a parameter.
105
- #
106
- # `ubound`
107
- # : Upper bound of prime numbers. The iterator stops after it yields all prime
108
- # numbers p <= `ubound`.
109
- #
110
- def each: (?Integer? ubound, ?PseudoPrimeGenerator generator) { (Integer) -> void } -> void
111
- | (?Integer? ubound, ?PseudoPrimeGenerator generator) -> PseudoPrimeGenerator
112
-
113
- # <!--
114
- # rdoc-file=lib/prime.rb
115
- # - int_from_prime_division(pd)
116
- # -->
117
- # Re-composes a prime factorization and returns the product.
118
- #
119
- # For the decomposition:
120
- #
121
- # [[p_1, e_1], [p_2, e_2], ..., [p_n, e_n]],
122
- #
123
- # it returns:
124
- #
125
- # p_1**e_1 * p_2**e_2 * ... * p_n**e_n.
126
- #
127
- # ## Parameters
128
- # `pd`
129
- # : Array of pairs of integers. Each pair consists of a prime number -- a
130
- # prime factor -- and a natural number -- its exponent (multiplicity).
131
- #
132
- #
133
- # ## Example
134
- # Prime.int_from_prime_division([[3, 2], [5, 1]]) #=> 45
135
- # 3**2 * 5 #=> 45
136
- #
137
- def self.int_from_prime_division: (Array[[ Integer, Integer ]]) -> Integer
138
-
139
- # <!--
140
- # rdoc-file=lib/prime.rb
141
- # - int_from_prime_division(pd)
142
- # -->
143
- # Re-composes a prime factorization and returns the product.
144
- #
145
- # For the decomposition:
146
- #
147
- # [[p_1, e_1], [p_2, e_2], ..., [p_n, e_n]],
148
- #
149
- # it returns:
150
- #
151
- # p_1**e_1 * p_2**e_2 * ... * p_n**e_n.
152
- #
153
- # ## Parameters
154
- # `pd`
155
- # : Array of pairs of integers. Each pair consists of a prime number -- a
156
- # prime factor -- and a natural number -- its exponent (multiplicity).
157
- #
158
- #
159
- # ## Example
160
- # Prime.int_from_prime_division([[3, 2], [5, 1]]) #=> 45
161
- # 3**2 * 5 #=> 45
162
- #
163
- def int_from_prime_division: (Array[[ Integer, Integer ]]) -> Integer
164
-
165
- # <!--
166
- # rdoc-file=lib/prime.rb
167
- # - prime?(value, generator = Prime::Generator23.new)
168
- # -->
169
- # Returns true if `value` is a prime number, else returns false. Integer#prime?
170
- # is much more performant.
171
- #
172
- # ## Parameters
173
- #
174
- # `value`
175
- # : an arbitrary integer to be checked.
176
- # `generator`
177
- # : optional. A pseudo-prime generator.
178
- #
179
- def self.prime?: (Integer value, ?PseudoPrimeGenerator generator) -> bool
180
-
181
- # <!--
182
- # rdoc-file=lib/prime.rb
183
- # - prime?(value, generator = Prime::Generator23.new)
184
- # -->
185
- # Returns true if `value` is a prime number, else returns false. Integer#prime?
186
- # is much more performant.
187
- #
188
- # ## Parameters
189
- #
190
- # `value`
191
- # : an arbitrary integer to be checked.
192
- # `generator`
193
- # : optional. A pseudo-prime generator.
194
- #
195
- def prime?: (Integer value, ?PseudoPrimeGenerator generator) -> bool
196
-
197
- # <!--
198
- # rdoc-file=lib/prime.rb
199
- # - prime_division(value, generator = Prime::Generator23.new)
200
- # -->
201
- # Returns the factorization of `value`.
202
- #
203
- # For an arbitrary integer:
204
- #
205
- # p_1**e_1 * p_2**e_2 * ... * p_n**e_n,
206
- #
207
- # prime_division returns an array of pairs of integers:
208
- #
209
- # [[p_1, e_1], [p_2, e_2], ..., [p_n, e_n]].
210
- #
211
- # Each pair consists of a prime number -- a prime factor -- and a natural number
212
- # -- its exponent (multiplicity).
213
- #
214
- # ## Parameters
215
- # `value`
216
- # : An arbitrary integer.
217
- # `generator`
218
- # : Optional. A pseudo-prime generator. `generator`.succ must return the next
219
- # pseudo-prime number in ascending order. It must generate all prime
220
- # numbers, but may also generate non-prime numbers, too.
221
- #
222
- #
223
- # ### Exceptions
224
- # `ZeroDivisionError`
225
- # : when `value` is zero.
226
- #
227
- #
228
- # ## Example
229
- #
230
- # Prime.prime_division(45) #=> [[3, 2], [5, 1]]
231
- # 3**2 * 5 #=> 45
232
- #
233
- def self.prime_division: (Integer, ?PseudoPrimeGenerator generator) -> Array[[ Integer, Integer ]]
234
-
235
- # <!--
236
- # rdoc-file=lib/prime.rb
237
- # - prime_division(value, generator = Prime::Generator23.new)
238
- # -->
239
- # Returns the factorization of `value`.
240
- #
241
- # For an arbitrary integer:
242
- #
243
- # p_1**e_1 * p_2**e_2 * ... * p_n**e_n,
244
- #
245
- # prime_division returns an array of pairs of integers:
246
- #
247
- # [[p_1, e_1], [p_2, e_2], ..., [p_n, e_n]].
248
- #
249
- # Each pair consists of a prime number -- a prime factor -- and a natural number
250
- # -- its exponent (multiplicity).
251
- #
252
- # ## Parameters
253
- # `value`
254
- # : An arbitrary integer.
255
- # `generator`
256
- # : Optional. A pseudo-prime generator. `generator`.succ must return the next
257
- # pseudo-prime number in ascending order. It must generate all prime
258
- # numbers, but may also generate non-prime numbers, too.
259
- #
260
- #
261
- # ### Exceptions
262
- # `ZeroDivisionError`
263
- # : when `value` is zero.
264
- #
265
- #
266
- # ## Example
267
- #
268
- # Prime.prime_division(45) #=> [[3, 2], [5, 1]]
269
- # 3**2 * 5 #=> 45
270
- #
271
- def prime_division: (Integer, ?PseudoPrimeGenerator generator) -> Array[[ Integer, Integer ]]
272
-
273
- # Returns the singleton instance.
274
- #
275
- def self.instance: () -> Prime
276
-
277
- # <!-- rdoc-file=lib/prime.rb -->
278
- # An abstract class for enumerating pseudo-prime numbers.
279
- #
280
- # Concrete subclasses should override succ, next, rewind.
281
- #
282
- class PseudoPrimeGenerator
283
- # <!--
284
- # rdoc-file=lib/prime.rb
285
- # - new(ubound = nil)
286
- # -->
287
- #
288
- def initialize: (?Integer?) -> void
289
-
290
- include Enumerable[Integer]
291
-
292
- # <!--
293
- # rdoc-file=lib/prime.rb
294
- # - upper_bound()
295
- # -->
296
- # ----
297
- # <!--
298
- # rdoc-file=lib/prime.rb
299
- # - upper_bound=(ubound)
300
- # -->
301
- #
302
- attr_accessor upper_bound(): Integer?
303
-
304
- # <!--
305
- # rdoc-file=lib/prime.rb
306
- # - each() { |prime| ... }
307
- # -->
308
- # Iterates the given block for each prime number.
309
- #
310
- def each: () { (Integer) -> void } -> void
311
-
312
- # <!--
313
- # rdoc-file=lib/prime.rb
314
- # - next()
315
- # -->
316
- # alias of `succ`.
317
- #
318
- def next: () -> Integer
319
-
320
- # <!--
321
- # rdoc-file=lib/prime.rb
322
- # - rewind()
323
- # -->
324
- # Rewinds the internal position for enumeration.
325
- #
326
- # See `Enumerator`#rewind.
327
- #
328
- def rewind: () -> void
329
-
330
- # <!--
331
- # rdoc-file=lib/prime.rb
332
- # - size()
333
- # -->
334
- #
335
- def size: () -> Float
336
-
337
- # <!--
338
- # rdoc-file=lib/prime.rb
339
- # - succ()
340
- # -->
341
- # returns the next pseudo-prime number, and move the internal position forward.
342
- #
343
- # `PseudoPrimeGenerator`#succ raises `NotImplementedError`.
344
- #
345
- def succ: () -> Integer
346
- end
347
-
348
- # <!-- rdoc-file=lib/prime.rb -->
349
- # An implementation of `PseudoPrimeGenerator`.
350
- #
351
- # Uses `EratosthenesSieve`.
352
- #
353
- class EratosthenesGenerator < PseudoPrimeGenerator
354
- end
355
-
356
- # <!-- rdoc-file=lib/prime.rb -->
357
- # An implementation of `PseudoPrimeGenerator` which uses a prime table generated
358
- # by trial division.
359
- #
360
- class TrialDivisionGenerator < PseudoPrimeGenerator
361
- end
362
-
363
- # <!-- rdoc-file=lib/prime.rb -->
364
- # Generates all integers which are greater than 2 and are not divisible by
365
- # either 2 or 3.
366
- #
367
- # This is a pseudo-prime generator, suitable on checking primality of an integer
368
- # by brute force method.
369
- #
370
- class Generator23 < PseudoPrimeGenerator
371
- end
372
- end