steep 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +27 -0
  3. data/.gitmodules +3 -0
  4. data/CHANGELOG.md +5 -0
  5. data/README.md +48 -90
  6. data/Rakefile +10 -6
  7. data/Steepfile +1 -0
  8. data/bin/setup +1 -0
  9. data/bin/smoke_runner.rb +9 -14
  10. data/exe/rbs +3 -0
  11. data/exe/ruby-signature +3 -0
  12. data/exe/steep +1 -0
  13. data/lib/steep.rb +32 -26
  14. data/lib/steep/annotation_parser.rb +167 -0
  15. data/lib/steep/ast/annotation/collection.rb +7 -7
  16. data/lib/steep/ast/types.rb +60 -0
  17. data/lib/steep/ast/types/any.rb +1 -1
  18. data/lib/steep/ast/types/factory.rb +535 -0
  19. data/lib/steep/ast/types/name.rb +3 -3
  20. data/lib/steep/ast/types/var.rb +1 -1
  21. data/lib/steep/cli.rb +56 -240
  22. data/lib/steep/drivers/annotations.rb +36 -19
  23. data/lib/steep/drivers/check.rb +55 -91
  24. data/lib/steep/drivers/init.rb +54 -0
  25. data/lib/steep/drivers/langserver.rb +241 -150
  26. data/lib/steep/drivers/print_project.rb +56 -0
  27. data/lib/steep/drivers/signature_error_printer.rb +25 -0
  28. data/lib/steep/drivers/trace_printer.rb +25 -0
  29. data/lib/steep/drivers/utils/driver_helper.rb +26 -0
  30. data/lib/steep/drivers/validate.rb +18 -38
  31. data/lib/steep/drivers/vendor.rb +46 -0
  32. data/lib/steep/drivers/watch.rb +78 -140
  33. data/lib/steep/errors.rb +22 -13
  34. data/lib/steep/interface/interface.rb +91 -0
  35. data/lib/steep/interface/method.rb +0 -4
  36. data/lib/steep/interface/method_type.rb +362 -2
  37. data/lib/steep/interface/substitution.rb +22 -0
  38. data/lib/steep/project.rb +25 -233
  39. data/lib/steep/project/dsl.rb +132 -0
  40. data/lib/steep/project/file.rb +93 -76
  41. data/lib/steep/project/file_loader.rb +63 -0
  42. data/lib/steep/project/options.rb +7 -0
  43. data/lib/steep/project/target.rb +190 -0
  44. data/lib/steep/signature/errors.rb +25 -77
  45. data/lib/steep/signature/validator.rb +122 -0
  46. data/lib/steep/source.rb +12 -7
  47. data/lib/steep/subtyping/check.rb +357 -633
  48. data/lib/steep/subtyping/constraints.rb +2 -2
  49. data/lib/steep/subtyping/trace.rb +23 -0
  50. data/lib/steep/type_construction.rb +509 -455
  51. data/lib/steep/type_inference/constant_env.rb +16 -24
  52. data/lib/steep/type_inference/type_env.rb +26 -18
  53. data/lib/steep/version.rb +1 -1
  54. data/sample/Steepfile +6 -0
  55. data/sample/lib/conference.rb +12 -0
  56. data/sample/sig/conference.rbs +6 -0
  57. data/smoke/alias/Steepfile +4 -0
  58. data/smoke/alias/a.rb +2 -2
  59. data/smoke/alias/{a.rbi → a.rbs} +1 -1
  60. data/smoke/and/Steepfile +4 -0
  61. data/smoke/array/Steepfile +4 -0
  62. data/smoke/array/a.rb +2 -2
  63. data/smoke/array/b.rb +4 -4
  64. data/smoke/array/c.rb +2 -2
  65. data/smoke/block/Steepfile +5 -0
  66. data/smoke/block/{a.rbi → a.rbs} +1 -1
  67. data/smoke/block/{c.rbi → c.rbs} +0 -0
  68. data/smoke/block/d.rb +6 -6
  69. data/smoke/case/Steepfile +4 -0
  70. data/smoke/case/a.rb +4 -3
  71. data/smoke/class/Steepfile +4 -0
  72. data/smoke/class/a.rb +1 -4
  73. data/smoke/class/a.rbs +24 -0
  74. data/smoke/class/h.rb +6 -2
  75. data/smoke/class/{h.rbi → h.rbs} +1 -2
  76. data/smoke/class/i.rb +1 -2
  77. data/smoke/class/i.rbs +9 -0
  78. data/smoke/const/Steepfile +4 -0
  79. data/smoke/dstr/Steepfile +4 -0
  80. data/smoke/ensure/Steepfile +4 -0
  81. data/smoke/ensure/a.rb +1 -1
  82. data/smoke/enumerator/Steepfile +4 -0
  83. data/smoke/enumerator/a.rb +7 -7
  84. data/smoke/enumerator/b.rb +6 -6
  85. data/smoke/extension/Steepfile +4 -0
  86. data/smoke/extension/{a.rbi → a.rbs} +2 -2
  87. data/smoke/extension/{e.rbi → e.rbs} +2 -2
  88. data/smoke/hash/Steepfile +4 -0
  89. data/smoke/hash/{a.rbi → a.rbs} +0 -0
  90. data/smoke/hash/b.rb +2 -2
  91. data/smoke/hash/c.rb +1 -1
  92. data/smoke/hash/e.rbs +3 -0
  93. data/smoke/hash/f.rb +1 -1
  94. data/smoke/hello/Steepfile +4 -0
  95. data/smoke/hello/hello.rbs +7 -0
  96. data/smoke/if/Steepfile +4 -0
  97. data/smoke/implements/Steepfile +4 -0
  98. data/smoke/implements/a.rbs +6 -0
  99. data/smoke/initialize/Steepfile +4 -0
  100. data/smoke/initialize/a.rbs +3 -0
  101. data/smoke/integer/Steepfile +4 -0
  102. data/smoke/integer/a.rb +5 -3
  103. data/smoke/interface/Steepfile +4 -0
  104. data/smoke/interface/{a.rbi → a.rbs} +0 -0
  105. data/smoke/kwbegin/Steepfile +4 -0
  106. data/smoke/lambda/Steepfile +4 -0
  107. data/smoke/lambda/a.rb +9 -2
  108. data/smoke/literal/Steepfile +4 -0
  109. data/smoke/literal/{literal_methods.rbi → literal_methods.rbs} +0 -0
  110. data/smoke/map/Steepfile +4 -0
  111. data/smoke/map/a.rb +1 -1
  112. data/smoke/method/Steepfile +4 -0
  113. data/smoke/method/{a.rbi → a.rbs} +0 -0
  114. data/smoke/method/b.rb +1 -4
  115. data/smoke/method/d.rb +1 -0
  116. data/smoke/method/d.rbs +3 -0
  117. data/smoke/module/Steepfile +4 -0
  118. data/smoke/module/a.rb +1 -1
  119. data/smoke/module/a.rbs +16 -0
  120. data/smoke/module/c.rb +1 -1
  121. data/smoke/regexp/Steepfile +4 -0
  122. data/smoke/regexp/a.rb +2 -2
  123. data/smoke/regexp/b.rb +16 -16
  124. data/smoke/regression/Steepfile +5 -0
  125. data/smoke/regression/array.rb +2 -2
  126. data/smoke/regression/hash.rb +2 -2
  127. data/smoke/regression/poly_new.rb +2 -0
  128. data/smoke/regression/poly_new.rbs +4 -0
  129. data/smoke/regression/set_divide.rb +2 -2
  130. data/smoke/rescue/Steepfile +4 -0
  131. data/smoke/rescue/a.rb +1 -1
  132. data/smoke/self/Steepfile +4 -0
  133. data/smoke/self/a.rbs +4 -0
  134. data/smoke/skip/Steepfile +4 -0
  135. data/smoke/stdout/Steepfile +4 -0
  136. data/smoke/stdout/{a.rbi → a.rbs} +1 -1
  137. data/smoke/super/Steepfile +4 -0
  138. data/smoke/super/a.rbs +10 -0
  139. data/smoke/type_case/Steepfile +4 -0
  140. data/smoke/type_case/a.rb +1 -1
  141. data/smoke/yield/Steepfile +4 -0
  142. data/smoke/yield/a.rb +2 -2
  143. data/steep.gemspec +14 -7
  144. data/vendor/ruby-signature/.github/workflows/ruby.yml +27 -0
  145. data/vendor/ruby-signature/.gitignore +12 -0
  146. data/vendor/ruby-signature/.rubocop.yml +15 -0
  147. data/vendor/ruby-signature/BSDL +22 -0
  148. data/vendor/ruby-signature/COPYING +56 -0
  149. data/vendor/ruby-signature/Gemfile +6 -0
  150. data/vendor/ruby-signature/README.md +93 -0
  151. data/vendor/ruby-signature/Rakefile +66 -0
  152. data/vendor/ruby-signature/bin/annotate-with-rdoc +156 -0
  153. data/vendor/ruby-signature/bin/console +14 -0
  154. data/vendor/ruby-signature/bin/query-rdoc +103 -0
  155. data/vendor/ruby-signature/bin/setup +10 -0
  156. data/vendor/ruby-signature/bin/sort +88 -0
  157. data/vendor/ruby-signature/bin/test_runner.rb +17 -0
  158. data/vendor/ruby-signature/docs/CONTRIBUTING.md +97 -0
  159. data/vendor/ruby-signature/docs/sigs.md +148 -0
  160. data/vendor/ruby-signature/docs/stdlib.md +152 -0
  161. data/vendor/ruby-signature/docs/syntax.md +528 -0
  162. data/vendor/ruby-signature/exe/rbs +3 -0
  163. data/vendor/ruby-signature/exe/ruby-signature +7 -0
  164. data/vendor/ruby-signature/lib/ruby/signature.rb +64 -0
  165. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +29 -0
  166. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +29 -0
  167. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +391 -0
  168. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +364 -0
  169. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +52 -0
  170. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +54 -0
  171. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +534 -0
  172. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +28 -0
  173. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +152 -0
  174. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +172 -0
  175. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +921 -0
  176. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +283 -0
  177. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +138 -0
  178. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +126 -0
  179. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +189 -0
  180. data/vendor/ruby-signature/lib/ruby/signature/location.rb +104 -0
  181. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +125 -0
  182. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +93 -0
  183. data/vendor/ruby-signature/lib/ruby/signature/parser.y +1343 -0
  184. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +441 -0
  185. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +579 -0
  186. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +383 -0
  187. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +48 -0
  188. data/vendor/ruby-signature/lib/ruby/signature/test.rb +28 -0
  189. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +63 -0
  190. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +290 -0
  191. data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +58 -0
  192. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +324 -0
  193. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +185 -0
  194. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +256 -0
  195. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +72 -0
  196. data/vendor/ruby-signature/lib/ruby/signature/types.rb +932 -0
  197. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +140 -0
  198. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +49 -0
  199. data/vendor/ruby-signature/lib/ruby/signature/version.rb +5 -0
  200. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +271 -0
  201. data/vendor/ruby-signature/ruby-signature.gemspec +45 -0
  202. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +3 -0
  203. data/vendor/ruby-signature/stdlib/base64/base64.rbs +15 -0
  204. data/vendor/ruby-signature/stdlib/builtin/array.rbs +1997 -0
  205. data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +280 -0
  206. data/vendor/ruby-signature/stdlib/builtin/binding.rbs +177 -0
  207. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +35 -0
  208. data/vendor/ruby-signature/stdlib/builtin/class.rbs +145 -0
  209. data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +116 -0
  210. data/vendor/ruby-signature/stdlib/builtin/complex.rbs +400 -0
  211. data/vendor/ruby-signature/stdlib/builtin/constants.rbs +37 -0
  212. data/vendor/ruby-signature/stdlib/builtin/data.rbs +5 -0
  213. data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +2 -0
  214. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +419 -0
  215. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +606 -0
  216. data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +404 -0
  217. data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +260 -0
  218. data/vendor/ruby-signature/stdlib/builtin/errno.rbs +781 -0
  219. data/vendor/ruby-signature/stdlib/builtin/errors.rbs +582 -0
  220. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +193 -0
  221. data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +40 -0
  222. data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +68 -0
  223. data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +12 -0
  224. data/vendor/ruby-signature/stdlib/builtin/file.rbs +476 -0
  225. data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +59 -0
  226. data/vendor/ruby-signature/stdlib/builtin/float.rbs +696 -0
  227. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +121 -0
  228. data/vendor/ruby-signature/stdlib/builtin/hash.rbs +1029 -0
  229. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +710 -0
  230. data/vendor/ruby-signature/stdlib/builtin/io.rbs +683 -0
  231. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +574 -0
  232. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +135 -0
  233. data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +141 -0
  234. data/vendor/ruby-signature/stdlib/builtin/math.rbs +66 -0
  235. data/vendor/ruby-signature/stdlib/builtin/method.rbs +182 -0
  236. data/vendor/ruby-signature/stdlib/builtin/module.rbs +248 -0
  237. data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +82 -0
  238. data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +409 -0
  239. data/vendor/ruby-signature/stdlib/builtin/object.rbs +824 -0
  240. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +426 -0
  241. data/vendor/ruby-signature/stdlib/builtin/process.rbs +354 -0
  242. data/vendor/ruby-signature/stdlib/builtin/random.rbs +93 -0
  243. data/vendor/ruby-signature/stdlib/builtin/range.rbs +226 -0
  244. data/vendor/ruby-signature/stdlib/builtin/rational.rbs +424 -0
  245. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +10 -0
  246. data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +131 -0
  247. data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +14 -0
  248. data/vendor/ruby-signature/stdlib/builtin/signal.rbs +55 -0
  249. data/vendor/ruby-signature/stdlib/builtin/string.rbs +770 -0
  250. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +13 -0
  251. data/vendor/ruby-signature/stdlib/builtin/struct.rbs +40 -0
  252. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +230 -0
  253. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +1112 -0
  254. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +23 -0
  255. data/vendor/ruby-signature/stdlib/builtin/time.rbs +739 -0
  256. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +91 -0
  257. data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +46 -0
  258. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +159 -0
  259. data/vendor/ruby-signature/stdlib/builtin/warning.rbs +17 -0
  260. data/vendor/ruby-signature/stdlib/erb/erb.rbs +18 -0
  261. data/vendor/ruby-signature/stdlib/find/find.rbs +44 -0
  262. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +21 -0
  263. data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +23 -0
  264. data/vendor/ruby-signature/stdlib/prime/prime.rbs +188 -0
  265. data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +9 -0
  266. data/vendor/ruby-signature/stdlib/set/set.rbs +77 -0
  267. data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +53 -0
  268. metadata +244 -54
  269. data/.travis.yml +0 -7
  270. data/lib/steep/ast/signature/alias.rb +0 -19
  271. data/lib/steep/ast/signature/class.rb +0 -33
  272. data/lib/steep/ast/signature/const.rb +0 -17
  273. data/lib/steep/ast/signature/env.rb +0 -138
  274. data/lib/steep/ast/signature/extension.rb +0 -21
  275. data/lib/steep/ast/signature/gvar.rb +0 -17
  276. data/lib/steep/ast/signature/interface.rb +0 -31
  277. data/lib/steep/ast/signature/members.rb +0 -115
  278. data/lib/steep/ast/signature/module.rb +0 -21
  279. data/lib/steep/drivers/print_interface.rb +0 -94
  280. data/lib/steep/drivers/scaffold.rb +0 -321
  281. data/lib/steep/drivers/utils/each_signature.rb +0 -31
  282. data/lib/steep/interface/abstract.rb +0 -68
  283. data/lib/steep/interface/builder.rb +0 -637
  284. data/lib/steep/interface/instantiated.rb +0 -163
  285. data/lib/steep/interface/ivar_chain.rb +0 -26
  286. data/lib/steep/parser.y +0 -1278
  287. data/lib/steep/project/listener.rb +0 -53
  288. data/smoke/class/a.rbi +0 -24
  289. data/smoke/class/d.rb +0 -9
  290. data/smoke/class/e.rb +0 -12
  291. data/smoke/class/i.rbi +0 -9
  292. data/smoke/hash/e.rbi +0 -3
  293. data/smoke/hello/hello.rbi +0 -7
  294. data/smoke/implements/a.rbi +0 -6
  295. data/smoke/initialize/a.rbi +0 -3
  296. data/smoke/module/a.rbi +0 -16
  297. data/smoke/self/a.rbi +0 -4
  298. data/smoke/super/a.rbi +0 -10
  299. data/stdlib/builtin.rbi +0 -787
@@ -0,0 +1,404 @@
1
+ # The `Enumerable` mixin provides collection classes with several
2
+ # traversal and searching methods, and with the ability to sort. The class
3
+ # must provide a method `each`, which yields successive members of the
4
+ # collection. If `Enumerable#max`, `#min`, or `#sort` is used, the
5
+ # objects in the collection must also implement a meaningful `<=>`
6
+ # operator, as these methods rely on an ordering between members of the
7
+ # collection.
8
+ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
9
+ # Passes each element of the collection to the given block. The method
10
+ # returns `true` if the block never returns `false` or `nil` . If the
11
+ # block is not given, Ruby adds an implicit block of `{ |obj| obj }` which
12
+ # will cause [all?](Enumerable.downloaded.ruby_doc#method-i-all-3F) to
13
+ # return `true` when none of the collection members are `false` or `nil` .
14
+ #
15
+ # If instead a pattern is supplied, the method returns whether `pattern
16
+ # === element` for every collection member.
17
+ #
18
+ # %w[ant bear cat].all? { |word| word.length >= 3 } #=> true
19
+ # %w[ant bear cat].all? { |word| word.length >= 4 } #=> false
20
+ # %w[ant bear cat].all?(/t/) #=> false
21
+ # [1, 2i, 3.14].all?(Numeric) #=> true
22
+ # [nil, true, 99].all? #=> false
23
+ # [].all? #=> true
24
+ def all?: () -> bool
25
+ | () { (Elem arg0) -> untyped } -> bool
26
+
27
+ # Passes each element of the collection to the given block. The method
28
+ # returns `true` if the block ever returns a value other than `false` or
29
+ # `nil` . If the block is not given, Ruby adds an implicit block of `{
30
+ # |obj| obj }` that will cause
31
+ # [any?](Enumerable.downloaded.ruby_doc#method-i-any-3F) to return `true`
32
+ # if at least one of the collection members is not `false` or `nil` .
33
+ #
34
+ # If instead a pattern is supplied, the method returns whether `pattern
35
+ # === element` for any collection member.
36
+ #
37
+ # ```ruby
38
+ # %w[ant bear cat].any? { |word| word.length >= 3 } #=> true
39
+ # %w[ant bear cat].any? { |word| word.length >= 4 } #=> true
40
+ # %w[ant bear cat].any?(/d/) #=> false
41
+ # [nil, true, 99].any?(Integer) #=> true
42
+ # [nil, true, 99].any? #=> true
43
+ # [].any? #=> false
44
+ # ```
45
+ def `any?`: () -> bool
46
+ | () { (Elem arg0) -> untyped } -> bool
47
+
48
+ def collect: [U] () { (Elem arg0) -> U } -> ::Array[U]
49
+ | () -> ::Enumerator[Elem, Return]
50
+
51
+ def collect_concat: [U] () { (Elem arg0) -> ::Enumerator[U, untyped] } -> ::Array[U]
52
+
53
+ # Returns the number of items in `enum` through enumeration. If an
54
+ # argument is given, the number of items in `enum` that are equal to
55
+ # `item` are counted. If a block is given, it counts the number of
56
+ # elements yielding a true value.
57
+ #
58
+ # ```ruby
59
+ # ary = [1, 2, 4, 2]
60
+ # ary.count #=> 4
61
+ # ary.count(2) #=> 2
62
+ # ary.count{ |x| x%2==0 } #=> 3
63
+ # ```
64
+ def count: () -> Integer
65
+ | (?untyped arg0) -> Integer
66
+ | () { (Elem arg0) -> untyped } -> Integer
67
+
68
+ def cycle: (?Integer n) { (Elem arg0) -> untyped } -> NilClass
69
+ | (?Integer n) -> ::Enumerator[Elem, Return]
70
+
71
+ def detect: (?Proc ifnone) { (Elem arg0) -> untyped } -> Elem?
72
+ | (?Proc ifnone) -> ::Enumerator[Elem, Return]
73
+
74
+ def drop: (Integer n) -> ::Array[Elem]
75
+
76
+ def drop_while: () { (Elem arg0) -> untyped } -> ::Array[Elem]
77
+ | () -> ::Enumerator[Elem, Return]
78
+
79
+ def each_cons: (Integer n) { (::Array[Elem] arg0) -> untyped } -> NilClass
80
+ | (Integer n) -> ::Enumerator[::Array[Elem], Return]
81
+
82
+ def each_with_index: () { (Elem arg0, Integer arg1) -> untyped } -> ::Enumerable[Elem, Return]
83
+ | () -> ::Enumerator[[ Elem, Integer ], Return]
84
+
85
+ def each_with_object: [U] (U arg0) { (Elem arg0, untyped arg1) -> untyped } -> U
86
+ | [U] (U arg0) -> ::Enumerator[[ Elem, U ], Return]
87
+
88
+ # Returns an array containing the items in *enum* .
89
+ #
90
+ # ```ruby
91
+ # (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
92
+ # { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]
93
+ #
94
+ # require 'prime'
95
+ # Prime.entries 10 #=> [2, 3, 5, 7]
96
+ # ```
97
+ def entries: () -> ::Array[Elem]
98
+
99
+ def find_all: () { (Elem arg0) -> untyped } -> ::Array[Elem]
100
+ | () -> ::Enumerator[Elem, Return]
101
+
102
+ alias select find_all
103
+ alias filter find_all
104
+
105
+ def find_index: (?untyped value) -> Integer?
106
+ | () { (Elem arg0) -> untyped } -> Integer?
107
+ | () -> ::Enumerator[Elem, Return]
108
+
109
+ # Returns the first element, or the first `n` elements, of the enumerable.
110
+ # If the enumerable is empty, the first form returns `nil`, and the
111
+ # second form returns an empty array.
112
+ #
113
+ # ```ruby
114
+ # %w[foo bar baz].first #=> "foo"
115
+ # %w[foo bar baz].first(2) #=> ["foo", "bar"]
116
+ # %w[foo bar baz].first(10) #=> ["foo", "bar", "baz"]
117
+ # [].first #=> nil
118
+ # [].first(10) #=> []
119
+ # ```
120
+ def first: () -> Elem?
121
+ | (?Integer n) -> ::Array[Elem]?
122
+
123
+ def grep: (untyped arg0) -> ::Array[Elem]
124
+ | [U] (untyped arg0) { (Elem arg0) -> U } -> ::Array[U]
125
+
126
+ def grep_v: (untyped arg0) -> ::Array[Integer]
127
+ | [U] (untyped arg0) { (Elem arg0) -> U } -> ::Array[U]
128
+
129
+ def group_by: [U] () { (Elem arg0) -> U } -> ::Hash[U, ::Array[Elem]]
130
+ | () -> ::Enumerator[Elem, Return]
131
+
132
+ def `include?`: (untyped arg0) -> bool
133
+
134
+ def inject: (untyped init, Symbol method) -> untyped
135
+ | (Symbol method) -> untyped
136
+ | [A] (A initial) { (Elem, A) -> A } -> Elem
137
+ | () { (Elem, Elem) -> Elem } -> Elem
138
+
139
+ # Returns the object in *enum* with the maximum value. The first form
140
+ # assumes all objects implement `Comparable` ; the second uses the block
141
+ # to return *a \<=\> b* .
142
+ #
143
+ # ```ruby
144
+ # a = %w(albatross dog horse)
145
+ # a.max #=> "horse"
146
+ # a.max { |a, b| a.length <=> b.length } #=> "albatross"
147
+ # ```
148
+ #
149
+ # If the `n` argument is given, maximum `n` elements are returned as an
150
+ # array, sorted in descending order.
151
+ #
152
+ # ```ruby
153
+ # a = %w[albatross dog horse]
154
+ # a.max(2) #=> ["horse", "dog"]
155
+ # a.max(2) {|a, b| a.length <=> b.length } #=> ["albatross", "horse"]
156
+ # [5, 1, 3, 4, 2].max(3) #=> [5, 4, 3]
157
+ # ```
158
+ def max: () -> Elem?
159
+ | () { (Elem arg0, Elem arg1) -> Integer } -> Elem?
160
+ | (?Integer arg0) -> ::Array[Elem]
161
+ | (?Integer arg0) { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
162
+
163
+ def max_by: () -> ::Enumerator[Elem, Return]
164
+ | () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> Elem?
165
+ | (?Integer arg0) -> ::Enumerator[Elem, Return]
166
+ | (?Integer arg0) { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
167
+
168
+ # Returns the object in *enum* with the minimum value. The first form
169
+ # assumes all objects implement `Comparable` ; the second uses the block
170
+ # to return *a \<=\> b* .
171
+ #
172
+ # ```ruby
173
+ # a = %w(albatross dog horse)
174
+ # a.min #=> "albatross"
175
+ # a.min { |a, b| a.length <=> b.length } #=> "dog"
176
+ # ```
177
+ #
178
+ # If the `n` argument is given, minimum `n` elements are returned as a
179
+ # sorted array.
180
+ #
181
+ # ```ruby
182
+ # a = %w[albatross dog horse]
183
+ # a.min(2) #=> ["albatross", "dog"]
184
+ # a.min(2) {|a, b| a.length <=> b.length } #=> ["dog", "horse"]
185
+ # [5, 1, 3, 4, 2].min(3) #=> [1, 2, 3]
186
+ # ```
187
+ def min: () -> Elem?
188
+ | () { (Elem arg0, Elem arg1) -> Integer } -> Elem?
189
+ | (?Integer arg0) -> ::Array[Elem]
190
+ | (?Integer arg0) { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
191
+
192
+ def min_by: () -> ::Enumerator[Elem, Return]
193
+ | () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> Elem?
194
+ | (?Integer arg0) -> ::Enumerator[Elem, Return]
195
+ | (?Integer arg0) { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
196
+
197
+ # Returns a two element array which contains the minimum and the maximum
198
+ # value in the enumerable. The first form assumes all objects implement
199
+ # `Comparable` ; the second uses the block to return *a \<=\> b* .
200
+ #
201
+ # ```ruby
202
+ # a = %w(albatross dog horse)
203
+ # a.minmax #=> ["albatross", "horse"]
204
+ # a.minmax { |a, b| a.length <=> b.length } #=> ["dog", "albatross"]
205
+ # ```
206
+ def minmax: () -> [ Elem?, Elem? ]
207
+ | () { (Elem arg0, Elem arg1) -> Integer } -> [ Elem?, Elem? ]
208
+
209
+ def minmax_by: () -> [ Elem?, Elem? ]
210
+ | () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Enumerator[Elem, Return]
211
+
212
+ # Passes each element of the collection to the given block. The method
213
+ # returns `true` if the block never returns `true` for all elements. If
214
+ # the block is not given, `none?` will return `true` only if none of the
215
+ # collection members is true.
216
+ #
217
+ # If instead a pattern is supplied, the method returns whether `pattern
218
+ # === element` for none of the collection members.
219
+ #
220
+ # ```ruby
221
+ # %w{ant bear cat}.none? { |word| word.length == 5 } #=> true
222
+ # %w{ant bear cat}.none? { |word| word.length >= 4 } #=> false
223
+ # %w{ant bear cat}.none?(/d/) #=> true
224
+ # [1, 3.14, 42].none?(Float) #=> false
225
+ # [].none? #=> true
226
+ # [nil].none? #=> true
227
+ # [nil, false].none? #=> true
228
+ # [nil, false, true].none? #=> false
229
+ # ```
230
+ def none?: () -> bool
231
+ | () { (Elem arg0) -> untyped } -> bool
232
+
233
+ # Passes each element of the collection to the given block. The method
234
+ # returns `true` if the block returns `true` exactly once. If the block is
235
+ # not given, `one?` will return `true` only if exactly one of the
236
+ # collection members is true.
237
+ #
238
+ # If instead a pattern is supplied, the method returns whether `pattern
239
+ # === element` for exactly one collection member.
240
+ #
241
+ # ```ruby
242
+ # %w{ant bear cat}.one? { |word| word.length == 4 } #=> true
243
+ # %w{ant bear cat}.one? { |word| word.length > 4 } #=> false
244
+ # %w{ant bear cat}.one? { |word| word.length < 4 } #=> false
245
+ # %w{ant bear cat}.one?(/t/) #=> false
246
+ # [ nil, true, 99 ].one? #=> false
247
+ # [ nil, true, false ].one? #=> true
248
+ # [ nil, true, 99 ].one?(Integer) #=> true
249
+ # [].one? #=> false
250
+ # ```
251
+ def one?: () -> bool
252
+ | () { (Elem arg0) -> untyped } -> bool
253
+
254
+ def partition: () { (Elem arg0) -> untyped } -> [ ::Array[Elem], ::Array[Elem] ]
255
+ | () -> ::Enumerator[Elem, Return]
256
+
257
+ def reject: () { (Elem arg0) -> untyped } -> ::Array[Elem]
258
+ | () -> ::Enumerator[Elem, Return]
259
+
260
+ def reverse_each: () { (Elem arg0) -> untyped } -> ::Enumerator[Elem, Return]
261
+ | () -> ::Enumerator[Elem, Return]
262
+
263
+ # Returns an array containing the items in *enum* sorted.
264
+ #
265
+ # Comparisons for the sort will be done using the items’ own `<=>`
266
+ # operator or using an optional code block.
267
+ #
268
+ # The block must implement a comparison between `a` and `b` and return an
269
+ # integer less than 0 when `b` follows `a`, `0` when `a` and `b` are
270
+ # equivalent, or an integer greater than 0 when `a` follows `b` .
271
+ #
272
+ # The result is not guaranteed to be stable. When the comparison of two
273
+ # elements returns `0`, the order of the elements is unpredictable.
274
+ #
275
+ # ```ruby
276
+ # %w(rhea kea flea).sort #=> ["flea", "kea", "rhea"]
277
+ # (1..10).sort { |a, b| b <=> a } #=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
278
+ # ```
279
+ #
280
+ # See also [\#sort\_by](Enumerable.downloaded.ruby_doc#method-i-sort_by).
281
+ # It implements a Schwartzian transform which is useful when key
282
+ # computation or comparison is expensive.
283
+ def sort: () -> ::Array[Elem]
284
+ | () { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
285
+
286
+ def sort_by: () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
287
+ | () -> ::Enumerator[Elem, Return]
288
+
289
+ def take: (Integer n) -> ::Array[Elem]?
290
+
291
+ def take_while: () { (Elem arg0) -> untyped } -> ::Array[Elem]
292
+ | () -> ::Enumerator[Elem, Return]
293
+
294
+ # Implemented in C++
295
+ # Returns the result of interpreting *enum* as a list of `[key, value]`
296
+ # pairs.
297
+ #
298
+ # %i[hello world].each_with_index.to_h
299
+ # # => {:hello => 0, :world => 1}
300
+ #
301
+ # If a block is given, the results of the block on each element of the
302
+ # enum will be used as pairs.
303
+ #
304
+ # ```ruby
305
+ # (1..5).to_h {|x| [x, x ** 2]}
306
+ # #=> {1=>1, 2=>4, 3=>9, 4=>16, 5=>25}
307
+ # ```
308
+ def to_h: () -> ::Hash[untyped, untyped]
309
+
310
+ def each_slice: (Integer n) { (::Array[Elem] arg0) -> untyped } -> NilClass
311
+ | (Integer n) -> ::Enumerator[::Array[Elem], Return]
312
+
313
+ def find: (?Proc ifnone) { (Elem arg0) -> untyped } -> Elem?
314
+ | (?Proc ifnone) -> ::Enumerator[Elem, Return]
315
+
316
+ def flat_map: [U] () { (Elem arg0) -> U } -> U
317
+ | () -> ::Enumerator[Elem, Return]
318
+
319
+ def map: [U] () { (Elem arg0) -> U } -> ::Array[U]
320
+ | () -> ::Enumerator[Elem, Return]
321
+
322
+ def member?: (untyped arg0) -> bool
323
+
324
+ alias reduce inject
325
+
326
+ # Returns an array containing the items in *enum* .
327
+ #
328
+ # ```ruby
329
+ # (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
330
+ # { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]
331
+ #
332
+ # require 'prime'
333
+ # Prime.entries 10 #=> [2, 3, 5, 7]
334
+ # ```
335
+ def to_a: () -> ::Array[Elem]
336
+
337
+ # Returns a lazy enumerator, whose methods map/collect,
338
+ # flat\_map/collect\_concat, select/find\_all, reject, grep,
339
+ # [\#grep\_v](Enumerable.downloaded.ruby_doc#method-i-grep_v), zip, take,
340
+ # [\#take\_while](Enumerable.downloaded.ruby_doc#method-i-take_while),
341
+ # drop, and
342
+ # [\#drop\_while](Enumerable.downloaded.ruby_doc#method-i-drop_while)
343
+ # enumerate values only on an as-needed basis. However, if a block is
344
+ # given to zip, values are enumerated immediately.
345
+ #
346
+ #
347
+ # The following program finds pythagorean triples:
348
+ #
349
+ # ```ruby
350
+ # def pythagorean_triples
351
+ # (1..Float::INFINITY).lazy.flat_map {|z|
352
+ # (1..z).flat_map {|x|
353
+ # (x..z).select {|y|
354
+ # x**2 + y**2 == z**2
355
+ # }.map {|y|
356
+ # [x, y, z]
357
+ # }
358
+ # }
359
+ # }
360
+ # end
361
+ # # show first ten pythagorean triples
362
+ # p pythagorean_triples.take(10).force # take is lazy, so force is needed
363
+ # p pythagorean_triples.first(10) # first is eager
364
+ # # show pythagorean triples less than 100
365
+ # p pythagorean_triples.take_while { |*, z| z < 100 }.force
366
+ # ```
367
+ def lazy: () -> Enumerator::Lazy[Elem, Return]
368
+
369
+ def uniq: () -> ::Array[Elem]
370
+ | () { (Elem item) -> untyped } -> ::Array[Elem]
371
+
372
+ def sum: () -> (Elem | Integer)
373
+ | [T] () { (Elem arg0) -> T } -> (Integer | T)
374
+ | [T] (?T arg0) -> (Elem | T)
375
+ | [U] (?U arg0) { (Elem arg0) -> U } -> U
376
+
377
+ def filter_map: [U] () { (Elem arg0) -> U? } -> ::Array[U]
378
+ | () -> ::Enumerator[Elem, Return]
379
+
380
+ def chain: (*self enumerables) -> ::Enumerator::Chain[Elem, ::Array[self]]
381
+
382
+ def tally: () -> ::Hash[Elem, Integer]
383
+
384
+ def each_entry: () -> ::Enumerator[Elem, Return]
385
+ | () { (Elem arg0) -> untyped } -> self
386
+
387
+ # variadic type parameter is not supported yet
388
+ # https://github.com/ruby/ruby-signature/issues/21
389
+ def zip: [Elem2, Return2] (::Enumerable[Elem2, Return2] enum) -> ::Array[[Elem, Elem2 | nil]]
390
+ | [U, Elem2, Return2] (::Enumerable[Elem2, Return2]) { ([Elem, Elem2 | nil]) -> U } -> nil
391
+
392
+ def chunk: () -> ::Enumerator[Elem, Return]
393
+ | [U] () { (Elem elt) -> U } -> ::Enumerator[[U, Array[Elem]], void]
394
+
395
+ def chunk_while: () { (Elem elt_before, Elem elt_after) -> bool } -> ::Enumerator[::Array[Elem], void]
396
+
397
+ def slice_when: () { (Elem elt_before, Elem elt_after) -> bool } -> ::Enumerator[::Array[Elem], void]
398
+
399
+ def slice_after: (untyped pattern) -> ::Enumerator[::Array[Elem], void]
400
+ | () { (Elem elt) -> bool } -> ::Enumerator[::Array[Elem], void]
401
+
402
+ def slice_before: (untyped pattern) -> ::Enumerator[::Array[Elem], void]
403
+ | () { (Elem elt) -> bool } -> ::Enumerator[::Array[Elem], void]
404
+ end
@@ -0,0 +1,260 @@
1
+ # A class which allows both internal and external iteration.
2
+ #
3
+ # An [Enumerator](Enumerator) can be created by the
4
+ # following methods.
5
+ #
6
+ # - Kernel\#to\_enum
7
+ #
8
+ # - Kernel\#enum\_for
9
+ #
10
+ # - [::new](Enumerator#method-c-new)
11
+ #
12
+ # Most methods have two forms: a block form where the contents are
13
+ # evaluated for each item in the enumeration, and a non-block form which
14
+ # returns a new [Enumerator](Enumerator) wrapping the
15
+ # iteration.
16
+ #
17
+ # ```ruby
18
+ # enumerator = %w(one two three).each
19
+ # puts enumerator.class # => Enumerator
20
+ #
21
+ # enumerator.each_with_object("foo") do |item, obj|
22
+ # puts "#{obj}: #{item}"
23
+ # end
24
+ #
25
+ # # foo: one
26
+ # # foo: two
27
+ # # foo: three
28
+ #
29
+ # enum_with_obj = enumerator.each_with_object("foo")
30
+ # puts enum_with_obj.class # => Enumerator
31
+ #
32
+ # enum_with_obj.each do |item, obj|
33
+ # puts "#{obj}: #{item}"
34
+ # end
35
+ #
36
+ # # foo: one
37
+ # # foo: two
38
+ # # foo: three
39
+ # ```
40
+ #
41
+ # This allows you to chain Enumerators together. For example, you can map
42
+ # a list's elements to strings containing the index and the element as a
43
+ # string via:
44
+ #
45
+ # ```ruby
46
+ # puts %w[foo bar baz].map.with_index { |w, i| "#{i}:#{w}" }
47
+ # # => ["0:foo", "1:bar", "2:baz"]
48
+ # ```
49
+ #
50
+ # An [Enumerator](Enumerator) can also be used as an
51
+ # external iterator. For example,
52
+ # [\#next](Enumerator#method-i-next) returns the next
53
+ # value of the iterator or raises
54
+ # [StopIteration](https://ruby-doc.org/core-2.6.3/StopIteration.html) if
55
+ # the [Enumerator](Enumerator) is at the end.
56
+ #
57
+ # ```ruby
58
+ # e = [1,2,3].each # returns an enumerator object.
59
+ # puts e.next # => 1
60
+ # puts e.next # => 2
61
+ # puts e.next # => 3
62
+ # puts e.next # raises StopIteration
63
+ # ```
64
+ #
65
+ # You can use this to implement an internal iterator as follows:
66
+ #
67
+ # ```ruby
68
+ # def ext_each(e)
69
+ # while true
70
+ # begin
71
+ # vs = e.next_values
72
+ # rescue StopIteration
73
+ # return $!.result
74
+ # end
75
+ # y = yield(*vs)
76
+ # e.feed y
77
+ # end
78
+ # end
79
+ #
80
+ # o = Object.new
81
+ #
82
+ # def o.each
83
+ # puts yield
84
+ # puts yield(1)
85
+ # puts yield(1, 2)
86
+ # 3
87
+ # end
88
+ #
89
+ # # use o.each as an internal iterator directly.
90
+ # puts o.each {|*x| puts x; [:b, *x] }
91
+ # # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
92
+ #
93
+ # # convert o.each to an external iterator for
94
+ # # implementing an internal iterator.
95
+ # puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] }
96
+ # # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
97
+ # ```
98
+ class Enumerator[unchecked out Elem, out Return] < Object
99
+ include Enumerable[Elem, Return]
100
+
101
+ def each: () { (Elem arg0) -> untyped } -> Return
102
+ | () -> self
103
+
104
+ def feed: (Elem arg0) -> NilClass
105
+
106
+ def initialize: (?Integer arg0) { (Enumerator::Yielder arg0) -> void } -> void
107
+
108
+ # Creates a printable version of *e* .
109
+ def inspect: () -> String
110
+
111
+ # Returns the next object in the enumerator, and move the internal
112
+ # position forward. When the position reached at the end,
113
+ # [StopIteration](https://ruby-doc.org/core-2.6.3/StopIteration.html) is
114
+ # raised.
115
+ #
116
+ #
117
+ # ```ruby
118
+ # a = [1,2,3]
119
+ # e = a.to_enum
120
+ # p e.next #=> 1
121
+ # p e.next #=> 2
122
+ # p e.next #=> 3
123
+ # p e.next #raises StopIteration
124
+ # ```
125
+ #
126
+ # Note that enumeration sequence by `next` does not affect other
127
+ # non-external enumeration methods, unless the underlying iteration
128
+ # methods itself has side-effect, e.g.
129
+ # [IO\#each\_line](https://ruby-doc.org/core-2.6.3/IO.html#method-i-each_line)
130
+ # .
131
+ def next: () -> Elem
132
+
133
+ # Returns the next object as an array in the enumerator, and move the
134
+ # internal position forward. When the position reached at the end,
135
+ # [StopIteration](https://ruby-doc.org/core-2.6.3/StopIteration.html) is
136
+ # raised.
137
+ #
138
+ # This method can be used to distinguish `yield` and `yield nil` .
139
+ #
140
+ #
141
+ # ```ruby
142
+ # o = Object.new
143
+ # def o.each
144
+ # yield
145
+ # yield 1
146
+ # yield 1, 2
147
+ # yield nil
148
+ # yield [1, 2]
149
+ # end
150
+ # e = o.to_enum
151
+ # p e.next_values
152
+ # p e.next_values
153
+ # p e.next_values
154
+ # p e.next_values
155
+ # p e.next_values
156
+ # e = o.to_enum
157
+ # p e.next
158
+ # p e.next
159
+ # p e.next
160
+ # p e.next
161
+ # p e.next
162
+ #
163
+ # ## yield args next_values next
164
+ # # yield [] nil
165
+ # # yield 1 [1] 1
166
+ # # yield 1, 2 [1, 2] [1, 2]
167
+ # # yield nil [nil] nil
168
+ # # yield [1, 2] [[1, 2]] [1, 2]
169
+ # ```
170
+ #
171
+ # Note that `next_values` does not affect other non-external enumeration
172
+ # methods unless underlying iteration method itself has side-effect, e.g.
173
+ # [IO\#each\_line](https://ruby-doc.org/core-2.6.3/IO.html#method-i-each_line)
174
+ # .
175
+ def next_values: () -> ::Array[Elem]
176
+
177
+ # Returns the next object in the enumerator, but doesn’t move the internal
178
+ # position forward. If the position is already at the end,
179
+ # [StopIteration](https://ruby-doc.org/core-2.6.3/StopIteration.html) is
180
+ # raised.
181
+ #
182
+ #
183
+ # ```ruby
184
+ # a = [1,2,3]
185
+ # e = a.to_enum
186
+ # p e.next #=> 1
187
+ # p e.peek #=> 2
188
+ # p e.peek #=> 2
189
+ # p e.peek #=> 2
190
+ # p e.next #=> 2
191
+ # p e.next #=> 3
192
+ # p e.peek #raises StopIteration
193
+ # ```
194
+ def peek: () -> Elem
195
+
196
+ # Returns the next object as an array, similar to
197
+ # [\#next\_values](Enumerator.downloaded.ruby_doc#method-i-next_values),
198
+ # but doesn’t move the internal position forward. If the position is
199
+ # already at the end,
200
+ # [StopIteration](https://ruby-doc.org/core-2.6.3/StopIteration.html) is
201
+ # raised.
202
+ #
203
+ #
204
+ # ```ruby
205
+ # o = Object.new
206
+ # def o.each
207
+ # yield
208
+ # yield 1
209
+ # yield 1, 2
210
+ # end
211
+ # e = o.to_enum
212
+ # p e.peek_values #=> []
213
+ # e.next
214
+ # p e.peek_values #=> [1]
215
+ # p e.peek_values #=> [1]
216
+ # e.next
217
+ # p e.peek_values #=> [1, 2]
218
+ # e.next
219
+ # p e.peek_values # raises StopIteration
220
+ # ```
221
+ def peek_values: () -> ::Array[Elem]
222
+
223
+ # Rewinds the enumeration sequence to the beginning.
224
+ #
225
+ # If the enclosed object responds to a “rewind” method, it is called.
226
+ def rewind: () -> self
227
+
228
+ # Returns the size of the enumerator, or `nil` if it can’t be calculated
229
+ # lazily.
230
+ #
231
+ # ```ruby
232
+ # (1..100).to_a.permutation(4).size # => 94109400
233
+ # loop.size # => Float::INFINITY
234
+ # (1..100).drop_while.size # => nil
235
+ # ```
236
+ def size: () -> (Integer | Float)?
237
+
238
+ def with_index: (?Integer offset) { (Elem arg0, Integer arg1) -> untyped } -> Return
239
+ | (?Integer offset) -> ::Enumerator[[ Elem, Integer ], Return]
240
+
241
+ def with_object: [U] (U arg0) { (Elem arg0, U arg1) -> untyped } -> U
242
+ | [U] (U arg0) -> ::Enumerator[[ Elem, U ], Return]
243
+ end
244
+
245
+ class Enumerator::Generator[out Elem, out Return] < Object
246
+ include Enumerable[Elem, Return]
247
+ end
248
+
249
+ class Enumerator::Lazy[out Elem, out Return] < Enumerator[Elem, Return]
250
+ end
251
+
252
+ class Enumerator::Yielder < Object
253
+ def <<: (*untyped arg0) -> void
254
+
255
+ def yield: (*untyped arg0) -> void
256
+ end
257
+
258
+ class Enumerator::Chain[out Elem, out Return] < Object
259
+ include Enumerable[Elem, Return]
260
+ end