Module: Predicate::Expr
- Includes:
- Factory
- Included in:
- Contradiction, DyadicComp, Identifier, In, Intersect, Literal, Match, NadicBool, Native, Not, Opaque, QualifiedIdentifier, Tautology
- Defined in:
- lib/predicate/sequel.rb,
lib/predicate/nodes/expr.rb
Constant Summary
collapse
- OP_NEGATIONS =
{
:eq => :neq,
:neq => :eq,
:lt => :gte,
:lte => :gt,
:gt => :lte,
:gte => :lt
}
Instance Method Summary
collapse
Methods included from Factory
#and, #between, #comp, #contradiction, #from_hash, #identifier, #in, #intersect, #literal, #match, #native, #not, #opaque, #or, #placeholder, #qualified_identifier, #tautology
Instance Method Details
#! ⇒ Object
34
35
36
|
# File 'lib/predicate/nodes/expr.rb', line 34
def !
sexpr([:not, self])
end
|
#&(other) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/predicate/nodes/expr.rb', line 42
def &(other)
return other if other.contradiction?
return self if other.tautology?
return other & self if other.dyadic_priority > self.dyadic_priority
sexpr([:and, self, other])
end
|
#and_split(attr_list) ⇒ Object
55
56
57
58
|
# File 'lib/predicate/nodes/expr.rb', line 55
def and_split(attr_list)
(free_variables & attr_list).empty? ? [ tautology, self ] : [ self, tautology ]
end
|
#attr_split ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/predicate/nodes/expr.rb', line 60
def attr_split
if (vars = free_variables).size == 1
{ vars.first => self }
else
{ nil => self }
end
end
|
#bind(binding) ⇒ Object
84
85
86
|
# File 'lib/predicate/nodes/expr.rb', line 84
def bind(binding)
Binder.new(binding).call(self)
end
|
#constant_variables ⇒ Object
88
89
90
|
# File 'lib/predicate/nodes/expr.rb', line 88
def constant_variables
[]
end
|
#constants ⇒ Object
92
93
94
|
# File 'lib/predicate/nodes/expr.rb', line 92
def constants
{}
end
|
#contradiction? ⇒ Boolean
18
19
20
|
# File 'lib/predicate/nodes/expr.rb', line 18
def contradiction?
false
end
|
#dyadic_priority ⇒ Object
38
39
40
|
# File 'lib/predicate/nodes/expr.rb', line 38
def dyadic_priority
0
end
|
#identifier? ⇒ Boolean
30
31
32
|
# File 'lib/predicate/nodes/expr.rb', line 30
def identifier?
sexpr_type == :identifier
end
|
#literal? ⇒ Boolean
22
23
24
|
# File 'lib/predicate/nodes/expr.rb', line 22
def literal?
sexpr_type == :literal
end
|
#opaque? ⇒ Boolean
26
27
28
|
# File 'lib/predicate/nodes/expr.rb', line 26
def opaque?
sexpr_type == :opaque
end
|
#qualify(qualifier) ⇒ Object
76
77
78
|
# File 'lib/predicate/nodes/expr.rb', line 76
def qualify(qualifier)
Qualifier.new(qualifier).call(self)
end
|
#rename(renaming) ⇒ Object
72
73
74
|
# File 'lib/predicate/nodes/expr.rb', line 72
def rename(renaming)
Renamer.call(self, :renaming => renaming)
end
|
#sexpr(arg) ⇒ Object
100
101
102
|
# File 'lib/predicate/nodes/expr.rb', line 100
def sexpr(arg)
Factory.sexpr(arg)
end
|
#tautology? ⇒ Boolean
14
15
16
|
# File 'lib/predicate/nodes/expr.rb', line 14
def tautology?
false
end
|
#to_s(scope = nil) ⇒ Object
96
97
98
|
# File 'lib/predicate/nodes/expr.rb', line 96
def to_s(scope = nil)
ToS.call(self, scope: scope)
end
|
#to_sequel ⇒ Object
5
6
7
|
# File 'lib/predicate/sequel.rb', line 5
def to_sequel
ToSequel.call(self)
end
|
#unqualify ⇒ Object
80
81
82
|
# File 'lib/predicate/nodes/expr.rb', line 80
def unqualify
Unqualifier.new.call(self)
end
|
#|(other) ⇒ Object
49
50
51
52
53
|
# File 'lib/predicate/nodes/expr.rb', line 49
def |(other)
return other if other.tautology?
return self if other.contradiction?
sexpr([:or, self, other])
end
|