Sha256: 947117b14e15949a2ee1728070599a266879309f5b97961d75c2bd9fcb4b16d5

Contents?: true

Size: 655 Bytes

Versions: 8

Compression:

Stored size: 655 Bytes

Contents

require 'ffi/msgpack/types'
require 'ffi/msgpack/msg_object'

module FFI
  module MsgPack
    class MsgArray < FFI::Struct

      layout :size, :uint32,
             :ptr, :pointer

      #
      # The length of the MsgPack Array.
      #
      # @return [Integer]
      #   The length of the Array.
      #
      def length
        self[:size]
      end

      #
      # The Array of values.
      #
      # @return [Array<Object>]
      #   The values contained within the Array.
      #
      def to_a
        (0...self.length).map do |index|
          MsgObject.new(self[:ptr][index * MsgObject.size]).to_ruby
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ffi-msgpack-0.2.2 lib/ffi/msgpack/msg_array.rb
ffi-msgpack-0.2.1 lib/ffi/msgpack/msg_array.rb
ffi-msgpack-0.2.0 lib/ffi/msgpack/msg_array.rb
ffi-msgpack-0.1.4 lib/ffi/msgpack/msg_array.rb
ffi-msgpack-0.1.3 lib/ffi/msgpack/msg_array.rb
ffi-msgpack-0.1.2 lib/ffi/msgpack/msg_array.rb
ffi-msgpack-0.1.1 lib/ffi/msgpack/msg_array.rb
ffi-msgpack-0.1.0 lib/ffi/msgpack/msg_array.rb