steep 0.16.0 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -3
  3. data/CHANGELOG.md +6 -0
  4. data/Rakefile +0 -13
  5. data/bin/setup +0 -2
  6. data/bin/smoke_runner.rb +0 -1
  7. data/exe/steep +0 -1
  8. data/lib/steep/project/file.rb +1 -1
  9. data/lib/steep/project/hover_content.rb +1 -1
  10. data/lib/steep/server/code_worker.rb +1 -1
  11. data/lib/steep/server/signature_worker.rb +4 -4
  12. data/lib/steep/type_construction.rb +10 -16
  13. data/lib/steep/type_inference/constant_env.rb +2 -10
  14. data/lib/steep/type_inference/context.rb +1 -0
  15. data/lib/steep/version.rb +1 -1
  16. data/steep.gemspec +1 -5
  17. metadata +17 -135
  18. data/exe/rbs +0 -3
  19. data/vendor/ruby-signature/.github/workflows/ruby.yml +0 -27
  20. data/vendor/ruby-signature/.gitignore +0 -12
  21. data/vendor/ruby-signature/.rubocop.yml +0 -15
  22. data/vendor/ruby-signature/BSDL +0 -22
  23. data/vendor/ruby-signature/COPYING +0 -56
  24. data/vendor/ruby-signature/Gemfile +0 -6
  25. data/vendor/ruby-signature/README.md +0 -93
  26. data/vendor/ruby-signature/Rakefile +0 -142
  27. data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -157
  28. data/vendor/ruby-signature/bin/console +0 -14
  29. data/vendor/ruby-signature/bin/query-rdoc +0 -103
  30. data/vendor/ruby-signature/bin/setup +0 -10
  31. data/vendor/ruby-signature/bin/sort +0 -89
  32. data/vendor/ruby-signature/bin/test_runner.rb +0 -16
  33. data/vendor/ruby-signature/docs/CONTRIBUTING.md +0 -97
  34. data/vendor/ruby-signature/docs/sigs.md +0 -148
  35. data/vendor/ruby-signature/docs/stdlib.md +0 -152
  36. data/vendor/ruby-signature/docs/syntax.md +0 -528
  37. data/vendor/ruby-signature/exe/rbs +0 -7
  38. data/vendor/ruby-signature/lib/rbs.rb +0 -64
  39. data/vendor/ruby-signature/lib/rbs/ast/annotation.rb +0 -27
  40. data/vendor/ruby-signature/lib/rbs/ast/comment.rb +0 -27
  41. data/vendor/ruby-signature/lib/rbs/ast/declarations.rb +0 -395
  42. data/vendor/ruby-signature/lib/rbs/ast/members.rb +0 -362
  43. data/vendor/ruby-signature/lib/rbs/buffer.rb +0 -50
  44. data/vendor/ruby-signature/lib/rbs/builtin_names.rb +0 -55
  45. data/vendor/ruby-signature/lib/rbs/cli.rb +0 -558
  46. data/vendor/ruby-signature/lib/rbs/constant.rb +0 -26
  47. data/vendor/ruby-signature/lib/rbs/constant_table.rb +0 -150
  48. data/vendor/ruby-signature/lib/rbs/definition.rb +0 -170
  49. data/vendor/ruby-signature/lib/rbs/definition_builder.rb +0 -919
  50. data/vendor/ruby-signature/lib/rbs/environment.rb +0 -281
  51. data/vendor/ruby-signature/lib/rbs/environment_loader.rb +0 -136
  52. data/vendor/ruby-signature/lib/rbs/environment_walker.rb +0 -124
  53. data/vendor/ruby-signature/lib/rbs/errors.rb +0 -187
  54. data/vendor/ruby-signature/lib/rbs/location.rb +0 -102
  55. data/vendor/ruby-signature/lib/rbs/method_type.rb +0 -123
  56. data/vendor/ruby-signature/lib/rbs/namespace.rb +0 -91
  57. data/vendor/ruby-signature/lib/rbs/parser.y +0 -1344
  58. data/vendor/ruby-signature/lib/rbs/prototype/rb.rb +0 -553
  59. data/vendor/ruby-signature/lib/rbs/prototype/rbi.rb +0 -587
  60. data/vendor/ruby-signature/lib/rbs/prototype/runtime.rb +0 -381
  61. data/vendor/ruby-signature/lib/rbs/substitution.rb +0 -46
  62. data/vendor/ruby-signature/lib/rbs/test.rb +0 -26
  63. data/vendor/ruby-signature/lib/rbs/test/errors.rb +0 -61
  64. data/vendor/ruby-signature/lib/rbs/test/hook.rb +0 -294
  65. data/vendor/ruby-signature/lib/rbs/test/setup.rb +0 -58
  66. data/vendor/ruby-signature/lib/rbs/test/spy.rb +0 -325
  67. data/vendor/ruby-signature/lib/rbs/test/test_helper.rb +0 -183
  68. data/vendor/ruby-signature/lib/rbs/test/type_check.rb +0 -254
  69. data/vendor/ruby-signature/lib/rbs/type_name.rb +0 -70
  70. data/vendor/ruby-signature/lib/rbs/types.rb +0 -936
  71. data/vendor/ruby-signature/lib/rbs/variance_calculator.rb +0 -138
  72. data/vendor/ruby-signature/lib/rbs/vendorer.rb +0 -47
  73. data/vendor/ruby-signature/lib/rbs/version.rb +0 -3
  74. data/vendor/ruby-signature/lib/rbs/writer.rb +0 -269
  75. data/vendor/ruby-signature/lib/ruby/signature.rb +0 -7
  76. data/vendor/ruby-signature/rbs.gemspec +0 -46
  77. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -60
  78. data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -71
  79. data/vendor/ruby-signature/stdlib/benchmark/benchmark.rbs +0 -372
  80. data/vendor/ruby-signature/stdlib/builtin/array.rbs +0 -1997
  81. data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +0 -280
  82. data/vendor/ruby-signature/stdlib/builtin/binding.rbs +0 -177
  83. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +0 -45
  84. data/vendor/ruby-signature/stdlib/builtin/class.rbs +0 -145
  85. data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +0 -116
  86. data/vendor/ruby-signature/stdlib/builtin/complex.rbs +0 -400
  87. data/vendor/ruby-signature/stdlib/builtin/constants.rbs +0 -37
  88. data/vendor/ruby-signature/stdlib/builtin/data.rbs +0 -5
  89. data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +0 -2
  90. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +0 -413
  91. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -607
  92. data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +0 -404
  93. data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +0 -260
  94. data/vendor/ruby-signature/stdlib/builtin/errno.rbs +0 -781
  95. data/vendor/ruby-signature/stdlib/builtin/errors.rbs +0 -582
  96. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +0 -194
  97. data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +0 -40
  98. data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +0 -68
  99. data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +0 -12
  100. data/vendor/ruby-signature/stdlib/builtin/file.rbs +0 -1076
  101. data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +0 -59
  102. data/vendor/ruby-signature/stdlib/builtin/float.rbs +0 -696
  103. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +0 -243
  104. data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
  105. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -707
  106. data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
  107. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -576
  108. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -161
  109. data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -271
  110. data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -369
  111. data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -185
  112. data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -1104
  113. data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +0 -82
  114. data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +0 -409
  115. data/vendor/ruby-signature/stdlib/builtin/object.rbs +0 -824
  116. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +0 -429
  117. data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -1227
  118. data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -267
  119. data/vendor/ruby-signature/stdlib/builtin/range.rbs +0 -226
  120. data/vendor/ruby-signature/stdlib/builtin/rational.rbs +0 -424
  121. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +0 -57
  122. data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +0 -1083
  123. data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +0 -14
  124. data/vendor/ruby-signature/stdlib/builtin/signal.rbs +0 -55
  125. data/vendor/ruby-signature/stdlib/builtin/string.rbs +0 -1901
  126. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -284
  127. data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
  128. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -228
  129. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1108
  130. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
  131. data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -1047
  132. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -290
  133. data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
  134. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -153
  135. data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
  136. data/vendor/ruby-signature/stdlib/coverage/coverage.rbs +0 -62
  137. data/vendor/ruby-signature/stdlib/csv/csv.rbs +0 -773
  138. data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -392
  139. data/vendor/ruby-signature/stdlib/find/find.rbs +0 -40
  140. data/vendor/ruby-signature/stdlib/ipaddr/ipaddr.rbs +0 -247
  141. data/vendor/ruby-signature/stdlib/json/json.rbs +0 -335
  142. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -1093
  143. data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +0 -23
  144. data/vendor/ruby-signature/stdlib/prime/prime.rbs +0 -188
  145. data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +0 -9
  146. data/vendor/ruby-signature/stdlib/set/set.rbs +0 -301
  147. data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,23 +0,0 @@
1
- extension Integer (Prime)
2
- # Iterates the given block over all prime numbers.
3
- #
4
- # See Prime#each for more details.
5
- #
6
- def self.each_prime: (Integer) { (Integer) -> void } -> void
7
-
8
- # Re-composes a prime factorization and returns the product.
9
- #
10
- # See Prime#int_from_prime_division for more details.
11
- #
12
- def self.from_prime_division: (Array[[ String ]]) -> Integer
13
-
14
- # Returns the factorization of `self`.
15
- #
16
- # See Prime#prime_division for more details.
17
- #
18
- def prime_division: (?Prime::PseudoPrimeGenerator) -> Array[[ Integer, Integer ]]
19
-
20
- # Returns true if `self` is a prime number, else returns false.
21
- #
22
- def prime?: () -> bool
23
- end
@@ -1,188 +0,0 @@
1
- # The set of all prime numbers.
2
- #
3
- # ## Example
4
- #
5
- # Prime.each(100) do |prime|
6
- # p prime #=> 2, 3, 5, 7, 11, ...., 97
7
- # end
8
- #
9
- # Prime is Enumerable:
10
- #
11
- # Prime.first 5 # => [2, 3, 5, 7, 11]
12
- #
13
- # ## Retrieving the instance
14
- #
15
- # For convenience, each instance method of `Prime`.instance can be accessed as a
16
- # class method of `Prime`.
17
- #
18
- # e.g.
19
- # Prime.instance.prime?(2) #=> true
20
- # Prime.prime?(2) #=> true
21
- #
22
- # ## Generators
23
- #
24
- # A "generator" provides an implementation of enumerating pseudo-prime numbers
25
- # and it remembers the position of enumeration and upper bound. Furthermore, it
26
- # is an external iterator of prime enumeration which is compatible with an
27
- # Enumerator.
28
- #
29
- # `Prime`::`PseudoPrimeGenerator` is the base class for generators. There are
30
- # few implementations of generator.
31
- #
32
- # `Prime`::`EratosthenesGenerator`
33
- # : Uses eratosthenes' sieve.
34
- # `Prime`::`TrialDivisionGenerator`
35
- # : Uses the trial division method.
36
- # `Prime`::`Generator23`
37
- # : Generates all positive integers which are not divisible by either 2 or 3.
38
- # This sequence is very bad as a pseudo-prime sequence. But this is faster
39
- # and uses much less memory than the other generators. So, it is suitable
40
- # for factorizing an integer which is not large but has many prime factors.
41
- # e.g. for Prime#prime? .
42
- #
43
- #
44
- class Prime
45
- # Iterates the given block over all prime numbers.
46
- #
47
- # ## Parameters
48
- #
49
- # `ubound`
50
- # : Optional. An arbitrary positive number. The upper bound of enumeration.
51
- # The method enumerates prime numbers infinitely if `ubound` is nil.
52
- # `generator`
53
- # : Optional. An implementation of pseudo-prime generator.
54
- #
55
- #
56
- # ## Return value
57
- #
58
- # An evaluated value of the given block at the last time. Or an enumerator which
59
- # is compatible to an `Enumerator` if no block given.
60
- #
61
- # ## Description
62
- #
63
- # Calls `block` once for each prime number, passing the prime as a parameter.
64
- #
65
- # `ubound`
66
- # : Upper bound of prime numbers. The iterator stops after it yields all prime
67
- # numbers p <= `ubound`.
68
- #
69
- def self?.each: (?Integer? ubound, ?PseudoPrimeGenerator generator) { (Integer) -> void } -> void
70
- | (?Integer? ubound, ?PseudoPrimeGenerator generator) -> PseudoPrimeGenerator
71
-
72
- # Re-composes a prime factorization and returns the product.
73
- #
74
- # ## Parameters
75
- # `pd`
76
- # : Array of pairs of integers. The each internal pair consists of a prime
77
- # number -- a prime factor -- and a natural number -- an exponent.
78
- #
79
- #
80
- # ## Example
81
- # For `[[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]]`, it returns:
82
- #
83
- # p_1**e_1 * p_2**e_2 * .... * p_n**e_n.
84
- #
85
- # Prime.int_from_prime_division([[2,2], [3,1]]) #=> 12
86
- #
87
- def self?.int_from_prime_division: (Array[[ Integer, Integer ]]) -> Integer
88
-
89
- # Returns true if `value` is a prime number, else returns false.
90
- #
91
- # ## Parameters
92
- #
93
- # `value`
94
- # : an arbitrary integer to be checked.
95
- # `generator`
96
- # : optional. A pseudo-prime generator.
97
- #
98
- def self?.prime?: (Integer value, ?PseudoPrimeGenerator generator) -> bool
99
-
100
- # Returns the factorization of `value`.
101
- #
102
- # ## Parameters
103
- # `value`
104
- # : An arbitrary integer.
105
- # `generator`
106
- # : Optional. A pseudo-prime generator. `generator`.succ must return the next
107
- # pseudo-prime number in the ascending order. It must generate all prime
108
- # numbers, but may also generate non prime numbers too.
109
- #
110
- #
111
- # ### Exceptions
112
- # `ZeroDivisionError`
113
- # : when `value` is zero.
114
- #
115
- #
116
- # ## Example
117
- # For an arbitrary integer:
118
- #
119
- # n = p_1**e_1 * p_2**e_2 * .... * p_n**e_n,
120
- #
121
- # prime_division(n) returns:
122
- #
123
- # [[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]].
124
- #
125
- # Prime.prime_division(12) #=> [[2,2], [3,1]]
126
- #
127
- def self?.prime_division: (Integer, ?PseudoPrimeGenerator generator) -> Array[[ Integer, Integer ]]
128
-
129
- # Returns the singleton instance.
130
- #
131
- def self.instance: () -> Prime
132
- end
133
-
134
- # An abstract class for enumerating pseudo-prime numbers.
135
- #
136
- # Concrete subclasses should override succ, next, rewind.
137
- #
138
- class Prime::PseudoPrimeGenerator
139
- def initialize: (?Integer?) -> void
140
-
141
- include Enumerable[Integer, void]
142
-
143
- attr_accessor upper_bound (): Integer?
144
-
145
- # Iterates the given block for each prime number.
146
- #
147
- def each: () { (Integer) -> void } -> void
148
-
149
- # alias of `succ`.
150
- #
151
- def next: () -> Integer
152
-
153
- # Rewinds the internal position for enumeration.
154
- #
155
- # See `Enumerator`#rewind.
156
- #
157
- def rewind: () -> void
158
-
159
- def size: () -> Float
160
-
161
- # returns the next pseudo-prime number, and move the internal position forward.
162
- #
163
- # `PseudoPrimeGenerator`#succ raises `NotImplementedError`.
164
- #
165
- def succ: () -> Integer
166
- end
167
-
168
- # An implementation of `PseudoPrimeGenerator`.
169
- #
170
- # Uses `EratosthenesSieve`.
171
- #
172
- class Prime::EratosthenesGenerator < PseudoPrimeGenerator
173
- end
174
-
175
- # An implementation of `PseudoPrimeGenerator` which uses a prime table generated
176
- # by trial division.
177
- #
178
- class Prime::TrialDivisionGenerator < PseudoPrimeGenerator
179
- end
180
-
181
- # Generates all integers which are greater than 2 and are not divisible by
182
- # either 2 or 3.
183
- #
184
- # This is a pseudo-prime generator, suitable on checking primality of an integer
185
- # by brute force method.
186
- #
187
- class Prime::Generator23 < PseudoPrimeGenerator
188
- end
@@ -1,9 +0,0 @@
1
- module SecureRandom
2
- def self.alphanumeric: (?Integer?) -> String
3
- def self.base64: (?Integer?) -> String
4
- def self.hex: (?Integer?) -> String
5
- def self.random_bytes: (?Integer?) -> String
6
- def self.random_number: (?Integer?) -> (Integer | Float)
7
- def self.urlsafe_base64: (?Integer?, ?bool?) -> String
8
- def self.uuid: () -> String
9
- end
@@ -1,301 +0,0 @@
1
- # Set implements a collection of unordered values with no duplicates. This is a
2
- # hybrid of Array's intuitive inter-operation facilities and Hash's fast lookup.
3
- #
4
- # Set is easy to use with Enumerable objects (implementing `each`). Most of the
5
- # initializer methods and binary operators accept generic Enumerable objects
6
- # besides sets and arrays. An Enumerable object can be converted to Set using
7
- # the `to_set` method.
8
- #
9
- # Set uses Hash as storage, so you must note the following points:
10
- #
11
- # * Equality of elements is determined according to Object#eql? and
12
- # Object#hash. Use Set#compare_by_identity to make a set compare its
13
- # elements by their identity.
14
- # * Set assumes that the identity of each element does not change while it is
15
- # stored. Modifying an element of a set will render the set to an
16
- # unreliable state.
17
- # * When a string is to be stored, a frozen copy of the string is stored
18
- # instead unless the original string is already frozen.
19
- #
20
- #
21
- # ## Comparison
22
- #
23
- # The comparison operators <, >, <=, and >= are implemented as shorthand for the
24
- # {proper_,}{subset?,superset?} methods. However, the <=> operator is
25
- # intentionally left out because not every pair of sets is comparable ({x, y}
26
- # vs. {x, z} for example).
27
- #
28
- # ## Example
29
- #
30
- # require 'set'
31
- # s1 = Set[1, 2] #=> #<Set: {1, 2}>
32
- # s2 = [1, 2].to_set #=> #<Set: {1, 2}>
33
- # s1 == s2 #=> true
34
- # s1.add("foo") #=> #<Set: {1, 2, "foo"}>
35
- # s1.merge([2, 6]) #=> #<Set: {1, 2, "foo", 6}>
36
- # s1.subset?(s2) #=> false
37
- # s2.subset?(s1) #=> true
38
- #
39
- # ## Contact
40
- #
41
- # - Akinori MUSHA <knu@iDaemons.org> (current maintainer)
42
- #
43
- class Set[A]
44
- # Creates a new set containing the elements of the given enumerable object.
45
- #
46
- # If a block is given, the elements of enum are preprocessed by the given block.
47
- #
48
- # Set.new([1, 2]) #=> #<Set: {1, 2}>
49
- # Set.new([1, 2, 1]) #=> #<Set: {1, 2}>
50
- # Set.new([1, 'c', :s]) #=> #<Set: {1, "c", :s}>
51
- # Set.new(1..5) #=> #<Set: {1, 2, 3, 4, 5}>
52
- # Set.new([1, 2, 3]) { |x| x * x } #=> #<Set: {1, 4, 9}>
53
- #
54
- def initialize: (_Each[A, untyped]) -> untyped
55
- | [X] (_Each[X, untyped]) { (X) -> A } -> untyped
56
- | (?nil) -> untyped
57
-
58
- # Creates a new set containing the given objects.
59
- #
60
- # Set[1, 2] # => #<Set: {1, 2}>
61
- # Set[1, 2, 1] # => #<Set: {1, 2}>
62
- # Set[1, 'c', :s] # => #<Set: {1, "c", :s}>
63
- #
64
- def self.[]: [X] (*X) -> Set[X]
65
-
66
- # Returns a new set containing elements common to the set and the given
67
- # enumerable object.
68
- #
69
- # Set[1, 3, 5] & Set[3, 2, 1] #=> #<Set: {3, 1}>
70
- # Set['a', 'b', 'z'] & ['a', 'b', 'c'] #=> #<Set: {"a", "b"}>
71
- #
72
- def &: (_Each[A, untyped]) -> self
73
-
74
- alias intersection &
75
-
76
- # Returns a new set built by merging the set and the elements of the given
77
- # enumerable object.
78
- #
79
- # Set[1, 2, 3] | Set[2, 4, 5] #=> #<Set: {1, 2, 3, 4, 5}>
80
- # Set[1, 5, 'z'] | (1..6) #=> #<Set: {1, 5, "z", 2, 3, 4, 6}>
81
- #
82
- def |: (_Each[A, untyped]) -> self
83
-
84
- alias union |
85
-
86
- alias + |
87
-
88
- # Returns a new set built by duplicating the set, removing every element that
89
- # appears in the given enumerable object.
90
- #
91
- # Set[1, 3, 5] - Set[1, 5] #=> #<Set: {3}>
92
- # Set['a', 'b', 'z'] - ['a', 'c'] #=> #<Set: {"b", "z"}>
93
- #
94
- def -: (_Each[A, untyped]) -> self
95
-
96
- alias difference -
97
-
98
- # Adds the given object to the set and returns self. Use `merge` to add many
99
- # elements at once.
100
- #
101
- # Set[1, 2].add(3) #=> #<Set: {1, 2, 3}>
102
- # Set[1, 2].add([3, 4]) #=> #<Set: {1, 2, [3, 4]}>
103
- # Set[1, 2].add(2) #=> #<Set: {1, 2}>
104
- #
105
- def add: (A) -> self
106
-
107
- alias << add
108
-
109
- # Adds the given object to the set and returns self. If the object is already
110
- # in the set, returns nil.
111
- #
112
- # Set[1, 2].add?(3) #=> #<Set: {1, 2, 3}>
113
- # Set[1, 2].add?([3, 4]) #=> #<Set: {1, 2, [3, 4]}>
114
- # Set[1, 2].add?(2) #=> nil
115
- #
116
- def add?: (A) -> self?
117
-
118
- # Returns true if the set contains the given object.
119
- #
120
- # Note that `include?` and `member?` do not test member equality using `==` as
121
- # do other Enumerables.
122
- #
123
- # See also Enumerable#include?
124
- #
125
- def include?: (untyped) -> bool
126
-
127
- alias member? include?
128
-
129
- # Returns a new set containing elements exclusive between the set and the given
130
- # enumerable object. (set ^ enum) is equivalent to ((set | enum) - (set &
131
- # enum)).
132
- #
133
- # Set[1, 2] ^ Set[2, 3] #=> #<Set: {3, 1}>
134
- # Set[1, 'b', 'c'] ^ ['b', 'd'] #=> #<Set: {"d", 1, "c"}>
135
- #
136
- def ^: (_Each[A, untyped]) -> self
137
-
138
- # Classifies the set by the return value of the given block and returns a hash
139
- # of {value => set of elements} pairs. The block is called once for each
140
- # element of the set, passing the element as parameter.
141
- #
142
- # require 'set'
143
- # files = Set.new(Dir.glob("*.rb"))
144
- # hash = files.classify { |f| File.mtime(f).year }
145
- # hash #=> {2000=>#<Set: {"a.rb", "b.rb"}>,
146
- # # 2001=>#<Set: {"c.rb", "d.rb", "e.rb"}>,
147
- # # 2002=>#<Set: {"f.rb"}>}
148
- #
149
- # Returns an enumerator if no block is given.
150
- #
151
- def classify: [X] () { (A) -> X } -> Hash[X, self]
152
-
153
- # Removes all elements and returns self.
154
- #
155
- # set = Set[1, 'c', :s] #=> #<Set: {1, "c", :s}>
156
- # set.clear #=> #<Set: {}>
157
- # set #=> #<Set: {}>
158
- #
159
- def clear: () -> self
160
-
161
- # Replaces the elements with ones returned by collect(). Returns an enumerator
162
- # if no block is given.
163
- #
164
- def collect!: () { (A) -> A } -> self
165
-
166
- alias map! collect!
167
-
168
- # Deletes the given object from the set and returns self. Use `subtract` to
169
- # delete many items at once.
170
- #
171
- def delete: (untyped) -> self
172
-
173
- # Deletes the given object from the set and returns self. If the object is not
174
- # in the set, returns nil.
175
- #
176
- def delete?: (untyped) -> self?
177
-
178
- # Deletes every element of the set for which block evaluates to true, and
179
- # returns self. Returns an enumerator if no block is given.
180
- #
181
- def delete_if: () { (A) -> untyped } -> self
182
-
183
- # Equivalent to Set#delete_if, but returns nil if no changes were made. Returns
184
- # an enumerator if no block is given.
185
- #
186
- def reject!: () { (A) -> untyped } -> self
187
-
188
- # Returns true if the set and the given set have no element in common. This
189
- # method is the opposite of `intersect?`.
190
- #
191
- # Set[1, 2, 3].disjoint? Set[3, 4] #=> false
192
- # Set[1, 2, 3].disjoint? Set[4, 5] #=> true
193
- #
194
- def disjoint?: (self) -> bool
195
-
196
- # Divides the set into a set of subsets according to the commonality defined by
197
- # the given block.
198
- #
199
- # If the arity of the block is 2, elements o1 and o2 are in common if
200
- # block.call(o1, o2) is true. Otherwise, elements o1 and o2 are in common if
201
- # block.call(o1) == block.call(o2).
202
- #
203
- # require 'set'
204
- # numbers = Set[1, 3, 4, 6, 9, 10, 11]
205
- # set = numbers.divide { |i,j| (i - j).abs == 1 }
206
- # set #=> #<Set: {#<Set: {1}>,
207
- # # #<Set: {11, 9, 10}>,
208
- # # #<Set: {3, 4}>,
209
- # # #<Set: {6}>}>
210
- #
211
- # Returns an enumerator if no block is given.
212
- #
213
- def divide: () { (A, A) -> untyped } -> Set[self]
214
- | () { (A) -> untyped } -> Set[self]
215
-
216
- # Calls the given block once for each element in the set, passing the element as
217
- # parameter. Returns an enumerator if no block is given.
218
- #
219
- def each: () { (A) -> void } -> self
220
-
221
- # Returns true if the set contains no elements.
222
- #
223
- def empty?: () -> bool
224
-
225
- # Returns a new set that is a copy of the set, flattening each containing set
226
- # recursively.
227
- #
228
- def flatten: () -> Set[untyped]
229
-
230
- # Returns true if the set and the given set have at least one element in common.
231
- #
232
- # Set[1, 2, 3].intersect? Set[4, 5] #=> false
233
- # Set[1, 2, 3].intersect? Set[3, 4] #=> true
234
- #
235
- def intersect?: () -> bool
236
-
237
- # Deletes every element of the set for which block evaluates to false, and
238
- # returns self. Returns an enumerator if no block is given.
239
- #
240
- def keep_if: () { (A) -> untyped } -> self
241
-
242
- # Returns the number of elements.
243
- #
244
- def size: () -> Integer
245
-
246
- alias length size
247
-
248
- # Merges the elements of the given enumerable object to the set and returns
249
- # self.
250
- #
251
- def merge: (_Each[A, untyped]) -> self
252
-
253
- # Returns true if the set is a subset of the given set.
254
- #
255
- def subset?: (self) -> bool
256
-
257
- def proper_subst?: (self) -> bool
258
-
259
- # Returns true if the set is a superset of the given set.
260
- #
261
- def superset?: (self) -> bool
262
-
263
- # Returns true if the set is a proper superset of the given set.
264
- #
265
- def proper_superset?: (self) -> bool
266
-
267
- # Replaces the contents of the set with the contents of the given enumerable
268
- # object and returns self.
269
- #
270
- # set = Set[1, 'c', :s] #=> #<Set: {1, "c", :s}>
271
- # set.replace([1, 2]) #=> #<Set: {1, 2}>
272
- # set #=> #<Set: {1, 2}>
273
- #
274
- def replace: (_Each[A, untyped]) -> self
275
-
276
- # Resets the internal state after modification to existing elements and returns
277
- # self.
278
- #
279
- # Elements will be reindexed and deduplicated.
280
- #
281
- def reset: () -> self
282
-
283
- # Equivalent to Set#keep_if, but returns nil if no changes were made. Returns an
284
- # enumerator if no block is given.
285
- #
286
- def select!: () { (A) -> untyped } -> self?
287
-
288
- # Deletes every element that appears in the given enumerable object and returns
289
- # self.
290
- #
291
- def subtract: (_Each[A, untyped]) -> self
292
-
293
- # Converts the set to an array. The order of elements is uncertain.
294
- #
295
- # Set[1, 2].to_a #=> [1, 2]
296
- # Set[1, 'c', :s].to_a #=> [1, "c", :s]
297
- #
298
- def to_a: () -> Array[A]
299
-
300
- include Enumerable[A, self]
301
- end