steep 0.16.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -3
- data/CHANGELOG.md +6 -0
- data/Rakefile +0 -13
- data/bin/setup +0 -2
- data/bin/smoke_runner.rb +0 -1
- data/exe/steep +0 -1
- data/lib/steep/project/file.rb +1 -1
- data/lib/steep/project/hover_content.rb +1 -1
- data/lib/steep/server/code_worker.rb +1 -1
- data/lib/steep/server/signature_worker.rb +4 -4
- data/lib/steep/type_construction.rb +10 -16
- data/lib/steep/type_inference/constant_env.rb +2 -10
- data/lib/steep/type_inference/context.rb +1 -0
- data/lib/steep/version.rb +1 -1
- data/steep.gemspec +1 -5
- metadata +17 -135
- data/exe/rbs +0 -3
- data/vendor/ruby-signature/.github/workflows/ruby.yml +0 -27
- data/vendor/ruby-signature/.gitignore +0 -12
- data/vendor/ruby-signature/.rubocop.yml +0 -15
- data/vendor/ruby-signature/BSDL +0 -22
- data/vendor/ruby-signature/COPYING +0 -56
- data/vendor/ruby-signature/Gemfile +0 -6
- data/vendor/ruby-signature/README.md +0 -93
- data/vendor/ruby-signature/Rakefile +0 -142
- data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -157
- data/vendor/ruby-signature/bin/console +0 -14
- data/vendor/ruby-signature/bin/query-rdoc +0 -103
- data/vendor/ruby-signature/bin/setup +0 -10
- data/vendor/ruby-signature/bin/sort +0 -89
- data/vendor/ruby-signature/bin/test_runner.rb +0 -16
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +0 -97
- data/vendor/ruby-signature/docs/sigs.md +0 -148
- data/vendor/ruby-signature/docs/stdlib.md +0 -152
- data/vendor/ruby-signature/docs/syntax.md +0 -528
- data/vendor/ruby-signature/exe/rbs +0 -7
- data/vendor/ruby-signature/lib/rbs.rb +0 -64
- data/vendor/ruby-signature/lib/rbs/ast/annotation.rb +0 -27
- data/vendor/ruby-signature/lib/rbs/ast/comment.rb +0 -27
- data/vendor/ruby-signature/lib/rbs/ast/declarations.rb +0 -395
- data/vendor/ruby-signature/lib/rbs/ast/members.rb +0 -362
- data/vendor/ruby-signature/lib/rbs/buffer.rb +0 -50
- data/vendor/ruby-signature/lib/rbs/builtin_names.rb +0 -55
- data/vendor/ruby-signature/lib/rbs/cli.rb +0 -558
- data/vendor/ruby-signature/lib/rbs/constant.rb +0 -26
- data/vendor/ruby-signature/lib/rbs/constant_table.rb +0 -150
- data/vendor/ruby-signature/lib/rbs/definition.rb +0 -170
- data/vendor/ruby-signature/lib/rbs/definition_builder.rb +0 -919
- data/vendor/ruby-signature/lib/rbs/environment.rb +0 -281
- data/vendor/ruby-signature/lib/rbs/environment_loader.rb +0 -136
- data/vendor/ruby-signature/lib/rbs/environment_walker.rb +0 -124
- data/vendor/ruby-signature/lib/rbs/errors.rb +0 -187
- data/vendor/ruby-signature/lib/rbs/location.rb +0 -102
- data/vendor/ruby-signature/lib/rbs/method_type.rb +0 -123
- data/vendor/ruby-signature/lib/rbs/namespace.rb +0 -91
- data/vendor/ruby-signature/lib/rbs/parser.y +0 -1344
- data/vendor/ruby-signature/lib/rbs/prototype/rb.rb +0 -553
- data/vendor/ruby-signature/lib/rbs/prototype/rbi.rb +0 -587
- data/vendor/ruby-signature/lib/rbs/prototype/runtime.rb +0 -381
- data/vendor/ruby-signature/lib/rbs/substitution.rb +0 -46
- data/vendor/ruby-signature/lib/rbs/test.rb +0 -26
- data/vendor/ruby-signature/lib/rbs/test/errors.rb +0 -61
- data/vendor/ruby-signature/lib/rbs/test/hook.rb +0 -294
- data/vendor/ruby-signature/lib/rbs/test/setup.rb +0 -58
- data/vendor/ruby-signature/lib/rbs/test/spy.rb +0 -325
- data/vendor/ruby-signature/lib/rbs/test/test_helper.rb +0 -183
- data/vendor/ruby-signature/lib/rbs/test/type_check.rb +0 -254
- data/vendor/ruby-signature/lib/rbs/type_name.rb +0 -70
- data/vendor/ruby-signature/lib/rbs/types.rb +0 -936
- data/vendor/ruby-signature/lib/rbs/variance_calculator.rb +0 -138
- data/vendor/ruby-signature/lib/rbs/vendorer.rb +0 -47
- data/vendor/ruby-signature/lib/rbs/version.rb +0 -3
- data/vendor/ruby-signature/lib/rbs/writer.rb +0 -269
- data/vendor/ruby-signature/lib/ruby/signature.rb +0 -7
- data/vendor/ruby-signature/rbs.gemspec +0 -46
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -60
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -71
- data/vendor/ruby-signature/stdlib/benchmark/benchmark.rbs +0 -372
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +0 -1997
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +0 -280
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +0 -177
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +0 -45
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +0 -145
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +0 -116
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +0 -400
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +0 -37
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +0 -5
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +0 -2
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +0 -413
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -607
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +0 -404
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +0 -260
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +0 -781
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +0 -582
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +0 -194
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +0 -68
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +0 -12
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +0 -1076
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +0 -59
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +0 -696
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +0 -243
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -707
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -576
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -161
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -271
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -369
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -185
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -1104
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +0 -82
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +0 -409
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +0 -824
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +0 -429
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -1227
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -267
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +0 -226
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +0 -424
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +0 -57
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +0 -1083
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +0 -14
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +0 -55
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +0 -1901
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -284
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -228
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1108
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -1047
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -290
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -153
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
- data/vendor/ruby-signature/stdlib/coverage/coverage.rbs +0 -62
- data/vendor/ruby-signature/stdlib/csv/csv.rbs +0 -773
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -392
- data/vendor/ruby-signature/stdlib/find/find.rbs +0 -40
- data/vendor/ruby-signature/stdlib/ipaddr/ipaddr.rbs +0 -247
- data/vendor/ruby-signature/stdlib/json/json.rbs +0 -335
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -1093
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +0 -23
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +0 -188
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +0 -9
- data/vendor/ruby-signature/stdlib/set/set.rbs +0 -301
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,404 +0,0 @@
|
|
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) { (A, Elem) -> A } -> A
|
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
|
@@ -1,260 +0,0 @@
|
|
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
|