Module: Predicate::Expr
- Includes:
- Factory
- Included in:
- Contradiction, DyadicComp, Identifier, In, Literal, NadicBool, Native, Not, 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, #literal, #native, #not, #or, #qualified_identifier, #tautology
Instance Method Details
#! ⇒ Object
22
23
24
|
# File 'lib/predicate/nodes/expr.rb', line 22
def !
sexpr([:not, self])
end
|
#&(other) ⇒ Object
26
27
28
29
30
|
# File 'lib/predicate/nodes/expr.rb', line 26
def &(other)
return other if other.contradiction?
return self if other.tautology?
sexpr([:and, self, other])
end
|
#and_split(attr_list) ⇒ Object
38
39
40
|
# File 'lib/predicate/nodes/expr.rb', line 38
def and_split(attr_list)
(free_variables & attr_list).empty? ? [ tautology, self ] : [ self, tautology ]
end
|
#constant_variables ⇒ Object
50
51
52
|
# File 'lib/predicate/nodes/expr.rb', line 50
def constant_variables
[]
end
|
#contradiction? ⇒ Boolean
18
19
20
|
# File 'lib/predicate/nodes/expr.rb', line 18
def contradiction?
false
end
|
#qualify(qualifier) ⇒ Object
46
47
48
|
# File 'lib/predicate/nodes/expr.rb', line 46
def qualify(qualifier)
Qualifier.new(qualifier).call(self)
end
|
#rename(renaming) ⇒ Object
42
43
44
|
# File 'lib/predicate/nodes/expr.rb', line 42
def rename(renaming)
Renamer.call(self, :renaming => renaming)
end
|
#sexpr(arg) ⇒ Object
63
64
65
|
# File 'lib/predicate/nodes/expr.rb', line 63
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_proc(scope = 't') ⇒ Object
59
60
61
|
# File 'lib/predicate/nodes/expr.rb', line 59
def to_proc(scope = 't')
Kernel.eval(to_ruby_code(scope))
end
|
#to_ruby_code(scope = 't') ⇒ Object
54
55
56
57
|
# File 'lib/predicate/nodes/expr.rb', line 54
def to_ruby_code(scope = 't')
code = ToRubyCode.call(self, scope: scope)
"->(t){ #{code} }"
end
|
#to_sequel ⇒ Object
5
6
7
|
# File 'lib/predicate/sequel.rb', line 5
def to_sequel
ToSequel.call(self)
end
|
#|(other) ⇒ Object
32
33
34
35
36
|
# File 'lib/predicate/nodes/expr.rb', line 32
def |(other)
return other if other.tautology?
return self if other.contradiction?
sexpr([:or, self, other])
end
|