Sha256: acf782b4b8a42cff2e865cafe3b0d2418ef2b946df0776d69552f96375d05946

Contents?: true

Size: 465 Bytes

Versions: 2

Compression:

Stored size: 465 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
      data.read_string 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

2 entries across 2 versions & 1 rubygems

Version Path
gir_ffi-0.11.1 lib/ffi-glib/byte_array.rb
gir_ffi-0.11.0 lib/ffi-glib/byte_array.rb