module Rubylog::Assertable
Public Instance Methods
if(body=nil, &block)
click to toggle source
Asserts a rule with the receiver as the head and the given argument or block as the body to the head’s predicate.
# File lib/rubylog/assertable.rb, line 4 def if body=nil, &block raise Rubylog::SyntaxError, "No body given", caller unless body || block predicate.assert(self, body || block) end
if!(body=nil, &block)
click to toggle source
Asserts a rule with the receiver as the head and the given argument or block as the body to the head’s predicate. Prepends a :cut! in front of the body with and .and().
# File lib/rubylog/assertable.rb, line 13 def if! body=nil, &block raise Rubylog::SyntaxError, "No body given", caller unless body || block predicate.assert self, :cut!.and(body || block) end
unless(body=nil, &block)
click to toggle source
Asserts a rule with the receiver as the head and the given argument or block as the body to the head’s predicate. Adds a .false to the body.
# File lib/rubylog/assertable.rb, line 20 def unless body=nil, &block raise Rubylog::SyntaxError, "No body given", caller unless body || block predicate.assert self, Rubylog::DefaultContext.false(body || block) end