Class: GLib::ByteArray

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi-glib/byte_array.rb

Overview

Overrides for GByteArray, GLib’s automatically growing array of bytes.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.newObject



18
19
20
# File 'lib/ffi-glib/byte_array.rb', line 18

def new
  wrap(Lib.g_byte_array_new)
end

Instance Method Details

#append(data) ⇒ Object



10
11
12
13
14
# File 'lib/ffi-glib/byte_array.rb', line 10

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

#to_stringObject



6
7
8
# File 'lib/ffi-glib/byte_array.rb', line 6

def to_string
  GirFFI::ArgHelper.ptr_to_utf8_length @struct[:data], @struct[:len]
end