Class: GLib::SizedArray
- Inherits:
-
Object
- Object
- GLib::SizedArray
- Includes:
- Enumerable
- Defined in:
- lib/ffi-glib/sized_array.rb
Overview
Class representing an array with a determined size
Instance Attribute Summary collapse
-
#element_type ⇒ Object
readonly
Returns the value of attribute element_type.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(element_type, size, pointer) ⇒ SizedArray
constructor
A new instance of SizedArray.
- #to_ptr ⇒ Object
Constructor Details
#initialize(element_type, size, pointer) ⇒ SizedArray
Returns a new instance of SizedArray.
7 8 9 10 11 |
# File 'lib/ffi-glib/sized_array.rb', line 7 def initialize element_type, size, pointer @element_type = element_type @size = size @pointer = pointer end |
Instance Attribute Details
#element_type ⇒ Object (readonly)
Returns the value of attribute element_type.
5 6 7 |
# File 'lib/ffi-glib/sized_array.rb', line 5 def element_type @element_type end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
5 6 7 |
# File 'lib/ffi-glib/sized_array.rb', line 5 def size @size end |
Class Method Details
.from(element_type, size, item) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ffi-glib/sized_array.rb', line 33 def from element_type, size, item return unless item case item when FFI::Pointer wrap element_type, size, item when self from_sized_array size, item else from_enumerable element_type, size, item end end |
.wrap(element_type, size, pointer) ⇒ Object
28 29 30 |
# File 'lib/ffi-glib/sized_array.rb', line 28 def self.wrap element_type, size, pointer new element_type, size, pointer unless pointer.null? end |
Instance Method Details
#each(&block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ffi-glib/sized_array.rb', line 17 def each &block # TODO: Move implementation from GirFFI::ArgHelper to here. # While doing so, the implentation could also become a real iterator arr = GirFFI::ArgHelper.ptr_to_typed_array(@element_type, @pointer, @size) if block_given? arr.each(&block) else arr.each end end |
#to_ptr ⇒ Object
13 14 15 |
# File 'lib/ffi-glib/sized_array.rb', line 13 def to_ptr @pointer end |