and(kind) { |oper| ... }
click to toggle source
def and(kind)
oper = new_oper(kind, 0x1)
yield oper if block_given?
end
and_not(kind) { |oper| ... }
click to toggle source
def and_not(kind)
oper = new_oper(kind, 0x5)
yield oper if block_given?
end
new_oper(kind, op)
click to toggle source
def new_oper(kind, op)
oper = Condition.generate(kind, self.watch)
@oper_stack.push(oper)
@op_stack.push(op)
oper
end
or(kind) { |oper| ... }
click to toggle source
def or(kind)
oper = new_oper(kind, 0x2)
yield oper if block_given?
end
or_not(kind) { |oper| ... }
click to toggle source
def or_not(kind)
oper = new_oper(kind, 0x6)
yield oper if block_given?
end
prepare()
click to toggle source
def prepare
@oper_stack.each { |oper| oper.prepare }
end
test()
click to toggle source
def test
if @this.nil?
if 0 < @op_stack[0] & AND
res = true
else
res = false
end
else
res = @this.test
end
@op_stack.each do |op|
cond = @oper_stack.shift
eval "res " + ((0 < op & AND) ? "&&" : "||") + "= " + ((0 < op & NOT) ? "!" : "") + "cond.test"
@oper_stack.push cond
end
res
end
this(kind) { |this| ... }
click to toggle source
def this(kind)
@this = Condition.generate(kind, self.watch)
yield @this if block_given?
end
valid?()
click to toggle source
def valid?
@oper_stack.inject(true) { |acc, oper| acc & oper.valid? }
end