class GLib::Bytes

Overrides for GBytes, GLib’s immutable array of bytes.

Public Class Methods

from(obj) click to toggle source
# File lib/ffi-glib/bytes.rb, line 14
def self.from(obj)
  case obj
  when self
    obj
  when FFI::Pointer
    wrap obj
  else
    new obj
  end
end
new(arr) click to toggle source
# File lib/ffi-glib/bytes.rb, line 25
def initialize(arr)
  data = GirFFI::SizedArray.from :guint8, arr.size, arr
  store_pointer Lib.g_bytes_new data.to_ptr, data.size
end

Public Instance Methods

each(&block) click to toggle source
# File lib/ffi-glib/bytes.rb, line 10
def each(&block)
  data.each(&block)
end

Private Instance Methods

data() click to toggle source
# File lib/ffi-glib/bytes.rb, line 32
def data
  @data ||= get_data
end