don't let the lookup return nil

This commit is contained in:
Vincent Batts 2012-08-06 14:37:28 -04:00
parent 28b6092ea3
commit 3e9789880d
2 changed files with 4 additions and 3 deletions

View file

@ -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)

View file

@ -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