Class: Cabriolet::HLP::QuickHelp::HuffmanTree::Node
- Inherits:
-
Object
- Object
- Cabriolet::HLP::QuickHelp::HuffmanTree::Node
- Defined in:
- lib/cabriolet/hlp/quickhelp/huffman_tree.rb
Overview
Node in the Huffman tree
Instance Attribute Summary collapse
-
#left_child ⇒ Object
Returns the value of attribute left_child.
-
#right_child ⇒ Object
Returns the value of attribute right_child.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
Instance Method Summary collapse
-
#initialize ⇒ Node
constructor
A new instance of Node.
- #leaf? ⇒ Boolean
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
17 18 19 20 21 |
# File 'lib/cabriolet/hlp/quickhelp/huffman_tree.rb', line 17 def initialize @symbol = nil @left_child = nil @right_child = nil end |
Instance Attribute Details
#left_child ⇒ Object
Returns the value of attribute left_child.
15 16 17 |
# File 'lib/cabriolet/hlp/quickhelp/huffman_tree.rb', line 15 def left_child @left_child end |
#right_child ⇒ Object
Returns the value of attribute right_child.
15 16 17 |
# File 'lib/cabriolet/hlp/quickhelp/huffman_tree.rb', line 15 def right_child @right_child end |
#symbol ⇒ Object
Returns the value of attribute symbol.
15 16 17 |
# File 'lib/cabriolet/hlp/quickhelp/huffman_tree.rb', line 15 def symbol @symbol end |
Instance Method Details
#leaf? ⇒ Boolean
23 24 25 |
# File 'lib/cabriolet/hlp/quickhelp/huffman_tree.rb', line 23 def leaf? @left_child.nil? && @right_child.nil? end |