Module: Factree
- Extended by:
- DSL
- Defined in:
- lib/factree.rb,
lib/factree/path.rb,
lib/factree/version.rb,
lib/factree/pathfinder.rb,
lib/factree/fact_source.rb
Defined Under Namespace
Modules: Aggregate, DSL, FactSource, Pathfinder Classes: Conclusion, Facts, FactsSpy, Path
Constant Summary collapse
- NoConclusionError =
Raised when attempting to get a conclusion from an incomplete path
Class.new(StandardError)
- VERSION =
"0.5.1"
- InvalidConclusionError =
Raised when a decision proc fails to return a Conclusion as expected
Class.new(StandardError)
Class Method Summary collapse
-
.conclusion(value = nil) ⇒ Conclusion
extended
from DSL
Creates a Conclusion to return from a decision proc.
-
.decide_between_alternatives(facts, *decide_procs) ⇒ Decision
extended
from DSL
A tool for composing lists of decision procs to be tried one after another until a conclusion is reached.
-
.find_path(**facts, &decide) ⇒ Path
extended
from DSL
Navigates as far as possible through a decision tree with the given set of facts.
Class Method Details
.conclusion(value = nil) ⇒ Conclusion Originally defined in module DSL
Creates a Conclusion to return from a decision proc.
The conclusion has an associated value (can be anything.)
.decide_between_alternatives(facts, *decide_procs) ⇒ Decision Originally defined in module DSL
A tool for composing lists of decision procs to be tried one after another until a conclusion is reached. When a proc returns nil instead of a Conclusion, the next proc in decide_procs is used instead.
If the last decision proc is reached and it returns nil, then this method returns nil.
.find_path(**facts, &decide) ⇒ Path Originally defined in module DSL
Navigates as far as possible through a decision tree with the given set of facts.
The path will stop when either
-
a conclusion is returned, or
-
there aren’t enough facts to make the decision.
Errors
If a decision function fails to return a Conclusion, an InvalidConclusionError will be raised.