Class: CBOR::Unpacker

Inherits:
Object
  • Object
show all
Defined in:
lib/cbor-packed.rb

Instance Method Summary collapse

Constructor Details

#initialize(match_array, prefix_array, suffix_array) ⇒ Unpacker

Returns a new instance of Unpacker.



133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/cbor-packed.rb', line 133

def initialize(match_array, prefix_array, suffix_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 prefix_array
  @prefix_array = []
  prefix_array.each {|x| @prefix_array << x.to_unpacked_cbor1(self)}
  @suffix_array = []
  suffix_array.each {|x| @prefix_array << x.to_unpacked_cbor1(self)}
  # XXX order? -- must do lazily!
end

Instance Method Details

#unprefix(n) ⇒ Object



151
152
153
# File 'lib/cbor-packed.rb', line 151

def unprefix(n)
  @prefix_array[n]
end

#unsimple(sv) ⇒ Object

XXX order? – must do lazily!



145
146
147
# File 'lib/cbor-packed.rb', line 145

def unsimple(sv)
  @simple_array[sv]
end

#unsuffix(n) ⇒ Object



154
155
156
# File 'lib/cbor-packed.rb', line 154

def unsuffix(n)
  @suffix_array[n]
end

#untag(tv) ⇒ Object



148
149
150
# File 'lib/cbor-packed.rb', line 148

def untag(tv)
  @tagged_array[(i << 1) ^ (i >> 63)]
end