Sha256: b828f64da475db3c6d78d02631e20deb82044d7214bc2fcdd65ffb2433c7d814

Contents?: true

Size: 343 Bytes

Versions: 1

Compression:

Stored size: 343 Bytes

Contents

module Huff
  class Encoder
    def initialize(tree)
      @table = EncodingTableBuilder.new(tree).table
    end

    def encode_string(text)
      text.each_char.each_with_object('') do |char, result|
        result << @table[char]
      end
    end

    def encode_36(text)
      encode_string(text).to_i(2).to_s(36).upcase
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
huff-0.0.1 lib/huff/encoder.rb