Sha256: acd5eaf8fbd75f265ab3259b56732dd2b005ee91623727f35334649f305b6ab0
Contents?: true
Size: 346 Bytes
Versions: 2
Compression:
Stored size: 346 Bytes
Contents
module Huff class EncodingTableBuilder def initialize(tree) @tree = tree end def table Hash[create_table(@tree, '')] end private def create_table(node, code) return [[node, code]] if node.is_a? String create_table(node.first, code + '0') + create_table(node.last, code + '1') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
huff-0.0.2 | lib/huff/encoding_table_builder.rb |
huff-0.0.1 | lib/huff/encoding_table_builder.rb |