Class: Delta::SetOperator
- Inherits:
-
Object
- Object
- Delta::SetOperator
show all
- Defined in:
- lib/delta/set_operator.rb,
lib/delta/set_operator/enumerable.rb,
lib/delta/set_operator/active_record.rb
Defined Under Namespace
Classes: ActiveRecord, Enumerable
Constant Summary
collapse
- ADAPTERS =
[ActiveRecord, Enumerable]
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(a:, b:, identifier:) ⇒ SetOperator
Returns a new instance of SetOperator.
12
13
14
15
16
|
# File 'lib/delta/set_operator.rb', line 12
def initialize(a:, b:, identifier:)
self.a = a
self.b = b
self.identifier = identifier
end
|
Class Method Details
.adapt(a:, b:, identifier:) ⇒ Object
5
6
7
8
9
10
|
# File 'lib/delta/set_operator.rb', line 5
def self.adapt(a:, b:, identifier:)
adapter = ADAPTERS.find { |klass| klass.compatible?(a, b) }
adapter = ADAPTERS.last unless adapter
adapter.new(a: a, b: b, identifier: identifier)
end
|
Instance Method Details
#intersection ⇒ Object
26
27
28
|
# File 'lib/delta/set_operator.rb', line 26
def intersection
intersect(a, b)
end
|
#subtract_a_from_b ⇒ Object
18
19
20
|
# File 'lib/delta/set_operator.rb', line 18
def subtract_a_from_b
subtract(b, a)
end
|
#subtract_b_from_a ⇒ Object
22
23
24
|
# File 'lib/delta/set_operator.rb', line 22
def subtract_b_from_a
subtract(a, b)
end
|