Class: MessagePack::Unpacker

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/jruby-msgpack/unpacker.rb

Instance Method Summary collapse

Constructor Details

#initializeUnpacker

Returns a new instance of Unpacker.



7
8
9
10
11
# File 'lib/jruby-msgpack/unpacker.rb', line 7

def initialize
  @msgpack  = org.msgpack.MessagePack.new
  @unpacker = org.msgpack.unpacker.MessagePackBufferUnpacker.new(@msgpack)
  @mapper   = TypeMapper.new
end

Instance Method Details

#eachObject



21
22
23
24
25
# File 'lib/jruby-msgpack/unpacker.rb', line 21

def each
  @unpacker.each do |mpo|
    yield @mapper.to_ruby_object(mpo)
  end
end

#feed(bytes) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/jruby-msgpack/unpacker.rb', line 13

def feed(bytes)
  if bytes.respond_to?(:to_java_bytes)
    @unpacker.feed(bytes.to_java_bytes)
  else
    @unpacker.feed(bytes)
  end
end