Sha256: 27dfde7bb864cef54961f0ec6a836c29484ac2849d0fb36872da8955506be487
Contents?: true
Size: 631 Bytes
Versions: 3
Compression:
Stored size: 631 Bytes
Contents
module Cborb::Decoding::Types # In CBOR, The process that decode some bytes as integer is popular. # Thus, we modularize that. module IntegerDecodable UNPACK_TEMPLATES = [ "C".freeze, "S>".freeze, "I>".freeze, "Q>".freeze, ].freeze # @param [Cborb::Decoding::State] state # @param [Integer] additional_info # @return [Integer] def consume_as_integer(state, additional_info) return additional_info if additional_info < 24 index = additional_info - 24 bytesize = 2**index state.consume(bytesize).unpack(UNPACK_TEMPLATES[index]).first end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cborb-0.3.0 | lib/cborb/decoding/types/integer_decodable.rb |
cborb-0.2.0 | lib/cborb/decoding/types/integer_decodable.rb |
cborb-0.1.0 | lib/cborb/decoding/types/integer_decodable.rb |