Class: MessagePack::Unpacker
- Inherits:
-
Object
- Object
- MessagePack::Unpacker
- Includes:
- Enumerable
- Defined in:
- lib/jruby-msgpack/unpacker.rb
Instance Method Summary collapse
- #each ⇒ Object
- #feed(bytes) ⇒ Object
-
#initialize ⇒ Unpacker
constructor
A new instance of Unpacker.
Constructor Details
#initialize ⇒ Unpacker
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
#each ⇒ Object
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 |