Class: RSpec::Core::Set
- Inherits:
-
Object
show all
- Includes:
- Enumerable
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/set.rb
Overview
We use this to replace ‘::Set` so we can have the advantage of constant time key lookups for unique arrays but without the potential to pollute a developers environment with an extra piece of the stdlib. This helps to prevent false positive builds.
Instance Method Summary
collapse
Methods included from Enumerable
#as_json, #compact_blank, #exclude?, #excluding, #in_order_of, #including, #index_by, #index_with, #many?, #maximum, #minimum, #pick, #pluck, #sole, #sum
Constructor Details
#initialize(array = []) ⇒ Set
Returns a new instance of Set.
14
15
16
17
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/set.rb', line 14
def initialize(array=[])
@values = {}
merge(array)
end
|
Instance Method Details
23
24
25
26
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/set.rb', line 23
def <<(key)
@values[key] = true
self
end
|
48
49
50
51
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/set.rb', line 48
def clear
@values.clear
self
end
|
#delete(key) ⇒ Object
28
29
30
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/set.rb', line 28
def delete(key)
@values.delete(key)
end
|
#each(&block) ⇒ Object
32
33
34
35
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/set.rb', line 32
def each(&block)
@values.keys.each(&block)
self
end
|
#empty? ⇒ Boolean
19
20
21
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/set.rb', line 19
def empty?
@values.empty?
end
|
#include?(key) ⇒ Boolean
37
38
39
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/set.rb', line 37
def include?(key)
@values.key?(key)
end
|
#merge(values) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/set.rb', line 41
def merge(values)
values.each do |key|
@values[key] = true
end
self
end
|