don't let the lookup return nil
This commit is contained in:
parent
28b6092ea3
commit
3e9789880d
2 changed files with 4 additions and 3 deletions
|
@ -89,11 +89,11 @@ class HuffmanEncoding
|
||||||
end
|
end
|
||||||
|
|
||||||
def encode(entry)
|
def encode(entry)
|
||||||
self.lookup.invert[entry]
|
self.lookup.invert[entry] || ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def decode(code)
|
def decode(code)
|
||||||
self.lookup[code]
|
self.lookup[code] || ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def encode_list(list)
|
def encode_list(list)
|
||||||
|
|
3
thing.rb
3
thing.rb
|
@ -21,7 +21,8 @@ end
|
||||||
require './huffman'
|
require './huffman'
|
||||||
|
|
||||||
$log = Logger.new(STDERR)
|
$log = Logger.new(STDERR)
|
||||||
$log.level = Logger::DEBUG
|
#$log.level = Logger::DEBUG
|
||||||
|
$log.level = Logger::FATAL
|
||||||
|
|
||||||
class BitWriter
|
class BitWriter
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue