Sha256: 1ac560370e97ceb4e27b92295c54812af887b8eec3ae2e189c596782c4f8a05b
Contents?: true
Size: 459 Bytes
Versions: 3
Compression:
Stored size: 459 Bytes
Contents
# frozen_string_literal: true module GLib # Common methods for GLib::Array and GLib::PtrArray module ArrayMethods # Re-implementation of the g_array_index and g_ptr_array_index macros def index(idx) unless (0...length).cover? idx raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}" end ptr = GirFFI::InOutPointer.new element_type, data_ptr + idx * element_size ptr.to_ruby_value end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gir_ffi-0.14.1 | lib/ffi-glib/array_methods.rb |
gir_ffi-0.14.0 | lib/ffi-glib/array_methods.rb |
gir_ffi-0.13.1 | lib/ffi-glib/array_methods.rb |