Sha256: 105ac38080c0e1e0e38e9b49ee88419f795951426242126e7b0b0de148f53e74

Contents?: true

Size: 709 Bytes

Versions: 3

Compression:

Stored size: 709 Bytes

Contents

module Cborb::Decoding::Types
  # To represent major type: 2(indefinite-length)
  #
  # @see https://tools.ietf.org/html/rfc7049#section-2.2.2
  class IndefiniteByteString < Type
    def self.indefinite?
      true
    end

    def self.decode(state, additional_info)
      state.push_stack(self, String.new.force_encoding(::Encoding::ASCII_8BIT))
    end

    def self.accept(im_data, type, value)
      if type == Cborb::Decoding::Types::ByteString
        im_data.concat(value)
        Cborb::Decoding::State::CONTINUE
      elsif type == Cborb::Decoding::Types::Break
        im_data
      else
        raise Cborb::DecodingError, "Unexpected chunk for indefinite byte string"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cborb-0.3.0 lib/cborb/decoding/types/indefinite_byte_string.rb
cborb-0.2.0 lib/cborb/decoding/types/indefinite_byte_string.rb
cborb-0.1.0 lib/cborb/decoding/types/indefinite_byte_string.rb