Module: Cborb

Defined in:
lib/cborb.rb,
lib/cborb/errors.rb,
lib/cborb/version.rb

Defined Under Namespace

Modules: Decoding Classes: DecodingError, Error, InvalidByteSequenceError

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.decode(cbor) ⇒ Object

The shorthand to decode CBOR

Parameters:

  • cbor (String)

Returns:

  • (Object)

    decoded data(Array, Hash, etc…)



40
41
42
43
44
45
46
47
48
49
# File 'lib/cborb.rb', line 40

def decode(cbor)
  decoder = Decoding::Decoder.new
  decoder.decode(cbor)

  if decoder.finished?
    decoder.result
  else
    raise Cborb::InvalidByteSequenceError
  end
end