Class: TreeThinking::BinaryTree
- Inherits:
-
Object
- Object
- TreeThinking::BinaryTree
- Defined in:
- lib/tree_thinking/binary_tree.rb
Defined Under Namespace
Classes: Node
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tree ⇒ Object
Returns the value of attribute tree.
Instance Method Summary collapse
- #call(answer_vector) ⇒ Object
-
#initialize(name: nil) ⇒ BinaryTree
constructor
A new instance of BinaryTree.
Constructor Details
#initialize(name: nil) ⇒ BinaryTree
Returns a new instance of BinaryTree.
8 9 10 |
# File 'lib/tree_thinking/binary_tree.rb', line 8 def initialize(name: nil) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/tree_thinking/binary_tree.rb', line 3 def name @name end |
#tree ⇒ Object
Returns the value of attribute tree.
4 5 6 |
# File 'lib/tree_thinking/binary_tree.rb', line 4 def tree @tree end |
Instance Method Details
#call(answer_vector) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/tree_thinking/binary_tree.rb', line 12 def call(answer_vector) node = self.tree while node.probablity.nil? do node = node.results.fetch(decision(node, answer_vector)) end node.probablity end |