Class: DecisionAgent::Dmn::DecisionNode
- Inherits:
-
Object
- Object
- DecisionAgent::Dmn::DecisionNode
- Defined in:
- lib/decision_agent/dmn/decision_graph.rb
Overview
Represents a decision in a decision graph
Instance Attribute Summary collapse
-
#decision_logic ⇒ Object
readonly
Returns the value of attribute decision_logic.
-
#evaluated ⇒ Object
Returns the value of attribute evaluated.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#information_requirements ⇒ Object
readonly
Returns the value of attribute information_requirements.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #add_dependency(decision_id, variable_name = nil) ⇒ Object
- #depends_on?(decision_id) ⇒ Boolean
-
#initialize(id:, name:, decision_logic: nil) ⇒ DecisionNode
constructor
A new instance of DecisionNode.
- #reset! ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(id:, name:, decision_logic: nil) ⇒ DecisionNode
Returns a new instance of DecisionNode.
14 15 16 17 18 19 20 21 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 14 def initialize(id:, name:, decision_logic: nil) @id = id @name = name @decision_logic = decision_logic # Can be DecisionTable, DecisionTree, or literal @information_requirements = [] # Dependencies on other decisions @value = nil @evaluated = false end |
Instance Attribute Details
#decision_logic ⇒ Object (readonly)
Returns the value of attribute decision_logic.
11 12 13 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 11 def decision_logic @decision_logic end |
#evaluated ⇒ Object
Returns the value of attribute evaluated.
12 13 14 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 12 def evaluated @evaluated end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 11 def id @id end |
#information_requirements ⇒ Object (readonly)
Returns the value of attribute information_requirements.
11 12 13 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 11 def information_requirements @information_requirements end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 11 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
12 13 14 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 12 def value @value end |
Instance Method Details
#add_dependency(decision_id, variable_name = nil) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 23 def add_dependency(decision_id, variable_name = nil) @information_requirements << { decision_id: decision_id, variable_name: variable_name || decision_id } end |
#depends_on?(decision_id) ⇒ Boolean
30 31 32 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 30 def depends_on?(decision_id) @information_requirements.any? { |req| req[:decision_id] == decision_id } end |
#reset! ⇒ Object
34 35 36 37 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 34 def reset! @value = nil @evaluated = false end |
#to_h ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/decision_agent/dmn/decision_graph.rb', line 39 def to_h { id: @id, name: @name, information_requirements: @information_requirements, decision_logic_type: decision_logic_type } end |