Class: Cborb::Decoding::Types::IndefiniteMap

Inherits:
Type
  • Object
show all
Defined in:
lib/cborb/decoding/types/indefinite_map.rb

Overview

To represent major type: 5(indefinite-length)

Class Method Summary collapse

Class Method Details

.accept(im_data, type, value) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/cborb/decoding/types/indefinite_map.rb', line 14

def self.accept(im_data, type, value)
  if type == Cborb::Decoding::Types::Break
    raise Cborb::DecodingError, "Invalid indefinite-length map" if im_data.size.odd?
    Hash[*im_data]
  else
    im_data << value
    Cborb::Decoding::State::CONTINUE
  end
end

.decode(state, additional_info) ⇒ Object



10
11
12
# File 'lib/cborb/decoding/types/indefinite_map.rb', line 10

def self.decode(state, additional_info)
  state.push_stack(self, [])
end

.indefinite?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/cborb/decoding/types/indefinite_map.rb', line 6

def self.indefinite?
  true
end