class FFI::Enum

def to_native(val, ctx)

Experimental RBS support (using type sampling data from the type_fusion project).

def to_native: ((Symbol | Integer) val, nil ctx) -> Integer

This signature was generated using 1967 samples from 5 applications.

Returns:
  • (Integer) - value of a enum symbol

Parameters:
  • ctx () -- unused
  • val (Symbol, Integer, #to_int) --
def to_native(val, ctx)
  @kv_map[val] || if val.is_a?(Integer)
    val
  elsif val.respond_to?(:to_int)
    val.to_int
  else
    raise ArgumentError, "invalid enum value, #{val.inspect}"
  end
end