Class: FFI::StructLayout::Enum

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

Overview

An enum Field in a FFI::StructLayout.

Instance Method Summary collapse

Methods inherited from Field

#alignment, #initialize, #name, #offset, #size, #type

Constructor Details

This class inherits a constructor from FFI::StructLayout::Field

Instance Method Details

#get(ptr) ⇒ Object

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

Parameters:

Returns:

  • (Object)


59
60
61
# File 'lib/ffi/struct.rb', line 59

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

#put(ptr, value) ⇒ nil

Set value into memory pointed by ptr.

Parameters:

Returns:

  • (nil)


67
68
69
# File 'lib/ffi/struct.rb', line 67

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