Class: Omnizip::Algorithms::BZip2::Huffman::Node
- Inherits:
-
Object
- Object
- Omnizip::Algorithms::BZip2::Huffman::Node
- Defined in:
- lib/omnizip/algorithms/bzip2/huffman.rb
Overview
Huffman tree node
Instance Attribute Summary collapse
-
#frequency ⇒ Object
Returns the value of attribute frequency.
-
#left ⇒ Object
Returns the value of attribute left.
-
#right ⇒ Object
Returns the value of attribute right.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
Instance Method Summary collapse
-
#initialize(symbol, frequency) ⇒ Node
constructor
Initialize node.
-
#leaf? ⇒ Boolean
Check if node is a leaf.
Constructor Details
#initialize(symbol, frequency) ⇒ Node
Initialize node
47 48 49 50 51 52 |
# File 'lib/omnizip/algorithms/bzip2/huffman.rb', line 47 def initialize(symbol, frequency) @symbol = symbol @frequency = frequency @left = nil @right = nil end |
Instance Attribute Details
#frequency ⇒ Object
Returns the value of attribute frequency.
41 42 43 |
# File 'lib/omnizip/algorithms/bzip2/huffman.rb', line 41 def frequency @frequency end |
#left ⇒ Object
Returns the value of attribute left.
41 42 43 |
# File 'lib/omnizip/algorithms/bzip2/huffman.rb', line 41 def left @left end |
#right ⇒ Object
Returns the value of attribute right.
41 42 43 |
# File 'lib/omnizip/algorithms/bzip2/huffman.rb', line 41 def right @right end |
#symbol ⇒ Object
Returns the value of attribute symbol.
41 42 43 |
# File 'lib/omnizip/algorithms/bzip2/huffman.rb', line 41 def symbol @symbol end |
Instance Method Details
#leaf? ⇒ Boolean
Check if node is a leaf
57 58 59 |
# File 'lib/omnizip/algorithms/bzip2/huffman.rb', line 57 def leaf? @left.nil? && @right.nil? end |