Class: GObjectIntrospection::Strv

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ffi-gobject_introspection/strv.rb

Overview

Represents a null-terminated array of strings. GLib uses this construction, but does not provide any actual functions for this class.

Direct Known Subclasses

GLib::Strv

Constant Summary collapse

POINTER_SIZE =
FFI.type_size(:pointer)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ Strv

Returns a new instance of Strv.



14
15
16
# File 'lib/ffi-gobject_introspection/strv.rb', line 14

def initialize(ptr)
  @ptr = ptr
end

Class Method Details

.wrap(ptr) ⇒ Object



30
31
32
# File 'lib/ffi-gobject_introspection/strv.rb', line 30

def self.wrap(ptr)
  new ptr
end

Instance Method Details

#eachObject



22
23
24
25
26
27
28
# File 'lib/ffi-gobject_introspection/strv.rb', line 22

def each
  offset = 0
  while (ptr = fetch_ptr offset)
    offset += POINTER_SIZE
    yield ptr.read_string
  end
end

#to_ptrObject



18
19
20
# File 'lib/ffi-gobject_introspection/strv.rb', line 18

def to_ptr
  @ptr
end