Class | FFI::Enum
In: | lib/ffi/enum.rb
Parent: | Object

Represents a C enum.

For a C enum:

     enum fruits {
       apple,
       banana,
       orange,
       pineapple
     };

are defined this vocabulary:

- a symbol is a word from the enumeration (ie. apple, by example);
- a value is the value of a symbol in the enumeration (by example, apple has value _0_ and banana _1_).

### Methods

[] find from_native native_type new symbol_map symbols to_h to_hash to_native

### Included Modules

DataConverter

### Attributes

tag | [R] |

### Public Class methods

new(info, tag=nil)

@param [nil, Enumerable] info @param tag enum tag

### Public Instance methods

[](query)

Get a symbol or a value from the enum. @overload [](query)

     Get enum value from symbol.
     @param [Symbol] query
     @return [Integer]

@overload [](query)

     Get enum symbol from value.
     @param [Integer] query
     @return [Symbol]

find(query)

Alias for #[]

from_native(val, ctx)

@param val @return symbol name if it exists for `val`.

native_type()

Get native type of Enum @return [Type::INT]

symbol_map()

Get the symbol map. @return [Hash]

symbols()

@return [Array] enum symbol names

to_h()

Alias for symbol_map

to_hash()

Alias for symbol_map

to_native(val, ctx)

@param [Symbol, Integer, to_int] val @param ctx unused @return [Integer] value of a enum symbol

[Validate]