Module: Predicate::Eq
- Includes:
- DyadicComp
- Defined in:
- lib/predicate/nodes/eq.rb
Constant Summary
Constants included
from Expr
Predicate::Expr::OP_NEGATIONS
Instance Method Summary
collapse
Methods included from DyadicComp
#!, #free_variables, #left, #priority, #right
Methods included from Expr
#!, #and_split, #attr_split, #contradiction?, #identifier?, #literal?, #opaque?, #qualify, #rename, #sexpr, #tautology?, #to_s, #to_sequel, #|
Methods included from Factory
#and, #between, #comp, #contradiction, #from_hash, #identifier, #in, #intersect, #literal, #match, #native, #not, #opaque, #or, #qualified_identifier, #tautology
Instance Method Details
#&(other) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/predicate/nodes/eq.rb', line 9
def &(other)
return super unless free_variables == other.free_variables
case other
when Eq
return self if constants == other.constants
return contradiction
when In
return self if other.right.literal?
end
super
rescue NotSupportedError
super
end
|
#constant_variables ⇒ Object
23
24
25
26
|
# File 'lib/predicate/nodes/eq.rb', line 23
def constant_variables
fv = free_variables
fv.size == 1 ? fv : []
end
|
#constants ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/predicate/nodes/eq.rb', line 28
def constants
left, right = sexpr(self.left), sexpr(self.right)
if left.identifier? && right.literal?
{ left.name => right.value }
elsif right.identifier? && left.literal?
{ right.name => left.value }
else
{}
end
end
|
#dyadic_priority ⇒ Object
39
40
41
|
# File 'lib/predicate/nodes/eq.rb', line 39
def dyadic_priority
900
end
|
#evaluate(tuple) ⇒ Object
43
44
45
|
# File 'lib/predicate/nodes/eq.rb', line 43
def evaluate(tuple)
left.evaluate(tuple) == right.evaluate(tuple)
end
|
#operator_symbol ⇒ Object
5
6
7
|
# File 'lib/predicate/nodes/eq.rb', line 5
def operator_symbol
:==
end
|