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) ⇒ Numeric

Get the offset of a field.

Returns:

  • (Numeric)


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

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

#offsetsArray<Array(Symbol, Numeric)>

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

Returns:

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

    Array<Array(Symbol, Numeric)>



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

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