Class: Cabriolet::HLP::QuickHelp::HuffmanTree::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/hlp/quickhelp/huffman_tree.rb

Overview

Node in the Huffman tree

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

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_childObject

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_childObject

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

#symbolObject

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

Returns:

  • (Boolean)


23
24
25
# File 'lib/cabriolet/hlp/quickhelp/huffman_tree.rb', line 23

def leaf?
  @left_child.nil? && @right_child.nil?
end