Sha256: 23e6ce37ef8a7a4ff0e38224a27a4b1edacf082b5e6a40b858e89b849b3e2cb4

Contents?: true

Size: 513 Bytes

Versions: 3

Compression:

Stored size: 513 Bytes

Contents

# frozen_string_literal: true
GLib.load_class :ByteArray

module GLib
  # Overrides for GByteArray, GLib's automatically growing array of bytes.
  class ByteArray
    def to_string
      GirFFI::ArgHelper.ptr_to_utf8_length @struct[:data], @struct[:len]
    end

    def append(data)
      bytes = GirFFI::InPointer.from :utf8, data
      len = data.bytesize
      self.class.wrap Lib.g_byte_array_append(to_ptr, bytes, len)
    end

    def initialize
      store_pointer(Lib.g_byte_array_new)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.9.5 lib/ffi-glib/byte_array.rb
gir_ffi-0.9.4 lib/ffi-glib/byte_array.rb
gir_ffi-0.9.3 lib/ffi-glib/byte_array.rb