Sha256: 45ce7c484d2fbf245740e51651129e74afff4da5a647dc9343f8ac04e759e5d8

Contents?: true

Size: 704 Bytes

Versions: 3

Compression:

Stored size: 704 Bytes

Contents

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

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

    def self.accept(im_data, type, value)
      if type == Cborb::Decoding::Types::TextString
        im_data.concat(value)
        Cborb::Decoding::State::CONTINUE
      elsif type == Cborb::Decoding::Types::Break
        im_data
      else
        raise Cborb::DecodingError, "Unexpected chunk for indefinite text 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_text_string.rb
cborb-0.2.0 lib/cborb/decoding/types/indefinite_text_string.rb
cborb-0.1.0 lib/cborb/decoding/types/indefinite_text_string.rb