Sha256: b90371c7a70a05ad66993b319a6e032dd8c439530996a19f1c5e583bf8e9682b

Contents?: true

Size: 466 Bytes

Versions: 9

Compression:

Stored size: 466 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

9 entries across 9 versions & 1 rubygems

Version Path
gir_ffi-0.14.1 lib/ffi-glib/byte_array.rb
gir_ffi-0.14.0 lib/ffi-glib/byte_array.rb
gir_ffi-0.13.1 lib/ffi-glib/byte_array.rb
gir_ffi-0.13.0 lib/ffi-glib/byte_array.rb
gir_ffi-0.12.1 lib/ffi-glib/byte_array.rb
gir_ffi-0.12.0 lib/ffi-glib/byte_array.rb
gir_ffi-0.11.4 lib/ffi-glib/byte_array.rb
gir_ffi-0.11.3 lib/ffi-glib/byte_array.rb
gir_ffi-0.11.2 lib/ffi-glib/byte_array.rb