Sha256: 1d44451c40e68c1317f0adbb33de923b5ee293da7ba388ee6a87437bce17275d

Contents?: true

Size: 602 Bytes

Versions: 2

Compression:

Stored size: 602 Bytes

Contents

module Cborb::Decoding::Types
  # To represent major type: 4(definite-length)
  #
  # @see https://tools.ietf.org/html/rfc7049#section-2.1
  class Array < Type
    extend Cborb::Decoding::Types::IntegerDecodable

    Intermediate = Struct.new(:size, :array)

    def self.decode(state, additional_info)
      im = Intermediate.new(consume_as_integer(state, additional_info), [])
      state.push_stack(self, im)
    end

    def self.accept(im_data, type, value)
      im_data.array << value
      im_data.size == im_data.array.size ? im_data.array : Cborb::Decoding::State::CONTINUE
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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