class School::Domain

Overview

A domain is a collection of facts.

Defined in:

school/domain/builder.cr
school/domain/domain.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Instantiates a new, empty domain.


[View source]

Instance Method Detail

def add(rule : Rule) : Rule #

Adds a rule to the domain.


[View source]
def assert(fact : Fact) : Fact #

Adds a fact to the domain.


[View source]
def facts #

Returns the facts in the domain.


[View source]
def remove(rule : Rule) : Rule #

Removes a rule from the domain.


[View source]
def retract(fact : Fact) : Fact #

Removes a fact from the domain.


[View source]
def rules #

Returns the rules in the domain.


[View source]
def run #

Runs the rules engine.

First, matches rules' conditions to facts, and then invokes rules' actions for each distinct match.

Rules are matched in order of their definition. Within a run, earlier rules can influence later rules (by asserting or retracting facts). Later rules cannot influence earlier rules.


[View source]