lib/gziprb/deflate.rb
def define_code_reader(bases:, extra_bits:, code_range:)
      Struct.new(:number_reader) do
        define_method(:next) do |code|
          raise "Unexpected code #{code} in #{self.class}" unless code_range.include?(code)

          index = code - code_range.min
          bits_to_read = extra_bits[index]

          bases[index] + (bits_to_read.positive? ? number_reader.call(bits_to_read) : 0)
        end
      end
    end
# Distance codes 0-31 are represented by (fixed-length) 5-bit codes, with possible additional
# bits as shown in the table shown in Paragraph 3.2.5, above. Note that distance codes 30-31
# will never actually occur in the compressed data.
Distance codes 0-31 are represented by (fixed-length) 5-bit codes, with possible additional
bits as shown in the table shown in Paragraph 3.2.5, above. Note that distance codes 30-31
will never actually occur in the compressed data.
Distance codes 0 - 31 are represented by ( fixed - length ) 5 - bit codes with possible additional bits as shown in the table shown in Paragraph 3 . 2 . 5 above . Note that distance codes 30 - 31 will never actually occur in the compressed data .
def define_code_reader(bases:, extra_bits:, code_range:)
      Struct.new(:number_reader) do
        define_method(:next) do |code|
          raise "Unexpected code #{code} in #{self.class}" unless code_range.include?(code)
          index = code - code_range.min
          bits_to_read = extra_bits[index]
          bases[index] + (bits_to_read.positive? ? number_reader.call(bits_to_read) : 0)
        end
      end
    end
def define_code_reader ( bases : , extra_bits : , code_range : ) Struct . new ( :number_reader ) do define_method ( :next ) do | code | raise "Unexpected code #{code} in #{self.class}" unless code_range . include? ( code ) index = code - code_range . min bits_to_read = extra_bits [ index ] bases [ index ] + ( bits_to_read . positive? ? number_reader . call ( bits_to_read ) : 0 ) end end end
Distance codes 0-31 are represented by (fixed-length) 5-bit codes, with possible additional
bits as shown in the table shown in Paragraph 3.2.5, above.
Distance codes 0 - 31 are represented by ( fixed - length ) 5 - bit codes with possible additional bits as shown in the table shown in Paragraph 3 . 2 . 5 above .
bases
extra_bits
code_range