Class: FFI::StructLayout::Enum

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

Overview

An enum Field in a FFI::StructLayout.

Instance Method Summary collapse

Instance Method Details

#get(ptr) ⇒ Object

Get an object of type #type from memory pointed by ptr.

Parameters:

Returns:

  • (Object)


56
57
58
# File 'lib/ffi/struct_layout.rb', line 56

def get(ptr)
  type.find(ptr.get_int(offset))
end

#put(ptr, value) ⇒ nil

Set value into memory pointed by ptr.

Parameters:

Returns:

  • (nil)


64
65
66
# File 'lib/ffi/struct_layout.rb', line 64

def put(ptr, value)
  ptr.put_int(offset, type.find(value))
end