Class: FFI::StructLayout

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi/struct_layout.rb

Defined Under Namespace

Classes: Enum, InnerStruct, Mapped

Instance Method Summary collapse

Instance Method Details

#offset_of(field_name) ⇒ Integer

Get the offset of a field.

Returns:

  • (Integer)


46
47
48
# File 'lib/ffi/struct_layout.rb', line 46

def offset_of(field_name)
  self[field_name].offset
end

#offsetsArray<Array(Symbol, Integer)>

Get an array of tuples (field name, offset of the field).

Returns:

  • (Array<Array(Symbol, Integer)>)

    Array<Array(Symbol, Integer)>



40
41
42
# File 'lib/ffi/struct_layout.rb', line 40

def offsets
  members.map { |m| [ m, self[m].offset ] }
end