Class: CBOR::Ibox
Constant Summary
Constants inherited from Box
Instance Attribute Summary
Attributes inherited from Box
Instance Method Summary collapse
Methods inherited from Box
#cbor_diagnostic, from_instance, #inspect, make_head, #to_s
Instance Method Details
#to_cbor ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/cbor-diag-support.rb', line 103 def to_cbor if ei = [:ei] maxval, plusbytes = INTEGER_EI[ei] raise ArgumentError, "cbor-diagnostic: unknown encoding indicator _#{ei} for Integer\n" unless maxval d = value ib = if d < 0 d = -1-d 0x20 else 0x00 end raise ArgumentError, "cbor-diagnostic: #{value} doesn't fit into encoding indicator _#{ei}':\n" unless d <= maxval CBOR::Ibox.make_head(ib, plusbytes, d) # s = bignum_to_bytes(d) # head(0xc0, TAG_BIGNUM_BASE + (ib >> 5)) # head(0x40, s.bytesize) else CBOR.encode(value) end end |