Class: TreeThinking::BinaryTreeFactory
- Inherits:
-
Object
- Object
- TreeThinking::BinaryTreeFactory
- Defined in:
- lib/tree_thinking/binary_tree_factory.rb
Instance Attribute Summary collapse
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Class Method Summary collapse
Instance Method Summary collapse
- #build! ⇒ Object
-
#initialize(tree) ⇒ BinaryTreeFactory
constructor
A new instance of BinaryTreeFactory.
Constructor Details
#initialize(tree) ⇒ BinaryTreeFactory
Returns a new instance of BinaryTreeFactory.
11 12 13 |
# File 'lib/tree_thinking/binary_tree_factory.rb', line 11 def initialize(tree) @tree = tree end |
Instance Attribute Details
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
5 6 7 |
# File 'lib/tree_thinking/binary_tree_factory.rb', line 5 def tree @tree end |
Class Method Details
.from_yaml(path) ⇒ Object
7 8 9 |
# File 'lib/tree_thinking/binary_tree_factory.rb', line 7 def self.from_yaml(path) new(YAML.load(File.read(path))).build! end |
Instance Method Details
#build! ⇒ Object
15 16 17 18 19 |
# File 'lib/tree_thinking/binary_tree_factory.rb', line 15 def build! btree = BinaryTree.new(name: tree['class_name']) btree.tree = nodify(tree['tree']) btree end |