class FFI::Bitmask

def to_native(query, ctx)

Returns:
  • (Integer) - value of a bitmask
  • (Integer) - value of a bitmask

Parameters:
  • ctx () -- unused
  • query (Array) --
  • ctx () -- unused
  • query (Symbol, Integer, #to_int) --

Overloads:
  • to_native(query, ctx)
  • to_native(query, ctx)
def to_native(query, ctx)
  return 0 if query.nil?
  flat_query = [query].flatten
  flat_query.inject(0) do |val, o|
    case o
    when Symbol
      v = @kv_map[o]
      raise ArgumentError, "invalid bitmask value, #{o.inspect}" unless v
      val |= v
    when Integer
      val |= o
    when ->(obj) { obj.respond_to?(:to_int) }
      val |= o.to_int
    else
      raise ArgumentError, "invalid bitmask value, #{o.inspect}"
    end
  end
end