class Rubylog::Procedure
Public Class Methods
new(functor, arity, rules=Array.new)
click to toggle source
Calls superclass method
Rubylog::Predicate::new
# File lib/rubylog/procedure.rb, line 5 def initialize functor, arity, rules=Array.new super functor, arity @rules = rules end
Public Instance Methods
assert(head, body=:true)
click to toggle source
Asserts a rule with a given head and body.
# File lib/rubylog/procedure.rb, line 41 def assert head, body=:true push Rubylog::Rule.new(head, body) end
call(*args) { || ... }
click to toggle source
accepts the *args of the called structure
# File lib/rubylog/procedure.rb, line 19 def call *args # catch cuts catch :rubylog_cut do # for each rule each do |rule| # compile rule = rule.rubylog_match_variables # unify the head with the arguments rule.head.args.rubylog_unify(args) do # call the body rule.body.prove do yield end end end end end
inspect()
click to toggle source
# File lib/rubylog/procedure.rb, line 10 def inspect "#{Rubylog::DSL::Indicators.humanize_indicator([functor,arity])}: #{@rules.inspect}" end
method_missing(name, *args, &block)
click to toggle source
# File lib/rubylog/procedure.rb, line 14 def method_missing name, *args, &block @rules.send name, *args, &block end