module FFI::MsgPack
Public Class Methods
pack(*objs)
click to toggle source
Packs a Ruby object.
@param [Array[Hash, Array
, String
, Symbol
, Integer
, Float
, true, false, nil]] objs
The Ruby object(s) to pack.
@return [String]
The packed Ruby object.
# File lib/ffi/msgpack/msgpack.rb, line 125 def MsgPack.pack(*objs) packer = Packer.create objs.each { |obj| packer << obj } return packer.to_s end
unpack(packed)
click to toggle source
Unpacks a packed object.
@param [String] packed
The packed object.
@return [Hash, Array
, String
, Symbol
, Integer
, Float
, true, false, nil]
The first unpacked Ruby object.
# File lib/ffi/msgpack/msgpack.rb, line 142 def MsgPack.unpack(packed) unpacker = Unpacker.create(packed.length) unpacker << packed return unpacker.first end
version()
click to toggle source
The version of libmsgpack.
@return [Gem::Version, nil]
The version of `libmsgpack`. `nil` will be returned if the version of `libmsgpack` is <= 0.5.1.
@since 0.1.4
# File lib/ffi/msgpack/msgpack.rb, line 29 def MsgPack.version if MsgPack.respond_to?(:msgpack_version) @version ||= Gem::Version.new(MsgPack.msgpack_version) end end