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

.from(data) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/ffi-glib/byte_array.rb', line 18

def self.from(data)
  case data
  when self
    data
  else
    new.append(data)
  end
end

Instance Method Details

#append(data) ⇒ Object



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

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



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

def to_string
  data.read_string len
end