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.

Instance Method Summary collapse

Constructor Details

#initializeByteArray

Returns a new instance of ByteArray.



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

def initialize
  store_pointer(Lib.g_byte_array_new)
end

Instance Method Details

#append(data) ⇒ Object



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

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

#to_stringObject



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

def to_string
  data.read_string len
end