Class: CBOR::Unpacker
- Inherits:
-
Object
- Object
- CBOR::Unpacker
- Defined in:
- lib/cbor-packed.rb
Instance Method Summary collapse
-
#initialize(match_array, argument_array) ⇒ Unpacker
constructor
A new instance of Unpacker.
- #unprefix(n) ⇒ Object
- #unsimple(sv) ⇒ Object
- #untag(i) ⇒ Object
Constructor Details
#initialize(match_array, argument_array) ⇒ Unpacker
Returns a new instance of Unpacker.
340 341 342 343 344 345 346 347 348 |
# File 'lib/cbor-packed.rb', line 340 def initialize(match_array, argument_array) @simple_array = match_array[0...16] @tagged_array = match_array[16..-1] # index with 2i for i >= 0 or ~2i for i < 0 # no map as we need to populate in progress # pp argument_array @argument_array = [] @raw_argument_array = argument_array end |
Instance Method Details
#unprefix(n) ⇒ Object
359 360 361 |
# File 'lib/cbor-packed.rb', line 359 def unprefix(n) @argument_array[n] ||= @raw_argument_array[n].to_unpacked_cbor1(self) end |
#unsimple(sv) ⇒ Object
349 350 351 |
# File 'lib/cbor-packed.rb', line 349 def unsimple(sv) @simple_array[sv].to_unpacked_cbor1(self) end |
#untag(i) ⇒ Object
352 353 354 355 356 357 358 |
# File 'lib/cbor-packed.rb', line 352 def untag(i) # @tagged_array[(i << 1) ^ (i >> 63)] ix = (i << 1) ^ (i >> 63) ret = @tagged_array[ix] # warn "** UNTAG i=#{i} ix=#{ix} ret=#{ret}" ret.to_unpacked_cbor1(self) end |