class Yadriggy::C::FFIArray

@abstract A wrapper of memory object accessible from Ruby and C code.

Public Class Methods

element_type() click to toggle source

Obtain the element type. All the subclasses have to override this method.

# File lib/yadriggy/c/ffi.rb, line 44
def self.element_type()
  Undef
end

Public Instance Methods

==(obj) click to toggle source
# File lib/yadriggy/c/ffi.rb, line 17
def ==(obj)
  obj.is_a?(FFIArray) && @array == obj.memory_pointer
end
length() click to toggle source

Obtain the size. @return [Integer] the number of elements.

# File lib/yadriggy/c/ffi.rb, line 29
def length() size() end
memory_pointer() click to toggle source

@return [FFI::MemoryPointer] the object holding all data.

# File lib/yadriggy/c/ffi.rb, line 13
def memory_pointer()
  @array
end
set_values() { |i| ... } click to toggle source

Initializes the element values.

# File lib/yadriggy/c/ffi.rb, line 32
def set_values
  size.times {|i| self[i] = yield i }
end
size() click to toggle source

Obtains the size. @return [Integer] the number of elements.

# File lib/yadriggy/c/ffi.rb, line 23
def size
  @array.size / @array.type_size
end
to_a(*args, &proc) click to toggle source

Converts all the elements into an array. This method is available only within Ruby.

# File lib/yadriggy/c/ffi.rb, line 38
def to_a(*args, &proc)
  Array.new(size) {|i| self[i] }
end