module Ikra::Types::ZipStructType::ZipStruct
A module that provides array-like functionality for FFI Struct types.
Public Class Methods
included(base)
click to toggle source
# File lib/types/types/struct_type.rb, line 127 def self.included(base) base.include(Enumerable) end
Public Instance Methods
[](index)
click to toggle source
Calls superclass method
# File lib/types/types/struct_type.rb, line 131 def [](index) # Out of bounds: returns nil return super(:"field_#{index}") end
[]=(index, value)
click to toggle source
Calls superclass method
# File lib/types/types/struct_type.rb, line 136 def []=(index, value) # TODO: What should we do if the type of a field changes? # Fill up missing slots with `nil` for id in (@fields.size)..index super(:"field_{id}", nil) end super(:"field_{index}", value) return value end
each() { |self| ... }
click to toggle source
# File lib/types/types/struct_type.rb, line 148 def each(&block) for index in 0...(@fields.size) yield(self[index]) end end