Sha256: a1f067e966eb7f9d0342c04d0b826fffa26a8ed96a0467e1474831b5835c2f9d

Contents?: true

Size: 859 Bytes

Versions: 1

Compression:

Stored size: 859 Bytes

Contents

module MessagePack
  class TypeMapper
    def to_ruby_object(message_pack_object)
      case message_pack_object.type
      when org.msgpack.type.ValueType::ARRAY
        message_pack_object.asArrayValue.elementArray.map { |o| to_ruby_object(o) }
      when org.msgpack.type.ValueType::BOOLEAN
        message_pack_object.asBooleanValue.getBoolean
      when org.msgpack.type.ValueType::FLOAT
        message_pack_object.asFloatValue.getDouble
      when org.msgpack.type.ValueType::INTEGER
        message_pack_object.asIntegerValue.getLong
      when org.msgpack.type.ValueType::MAP
        Hash[message_pack_object.asMapValue.map { |k, v| [to_ruby_object(k), to_ruby_object(v)] }]
      when org.msgpack.type.ValueType::NIL
        nil
      when org.msgpack.type.ValueType::RAW
        message_pack_object.asRawValue.getString
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jruby-msgpack-0.0.1 lib/jruby-msgpack/type_mapper.rb