Class: FFI::Enums

### Home Classes Methods

### In Files

- lib/ffi/enum.rb

### Parent

Object

### Methods

- ::new
- #<<
- #__map_symbol
- #find

### Files

- Makefile
- LICENSE
- compile
- configure
- depcomp
- stamp-vti
- install-sh
- libtool-version
- mdate-sh
- missing

### Class/Module Index

Quicksearch

- FFI
- FFI::AutoPointer
- FFI::AutoPointer::CallableReleaser
- FFI::AutoPointer::DefaultReleaser
- FFI::AutoPointer::Releaser
- FFI::ConstGenerator
- FFI::ConstGenerator::Constant
- FFI::Enum
- FFI::Enums
- FFI::Function
- FFI::FunctionType
- FFI::Generator
- FFI::Generator::Task
- FFI::IO
- FFI::LastError
- FFI::ManagedStruct
- FFI::MemoryPointer
- FFI::NativeType
- FFI::Platform
- FFI::PlatformError
- FFI::Pointer
- FFI::StrPtrConverter
- FFI::Struct
- FFI::Struct::InlineArray
- FFI::Struct::ManagedStructConverter
- FFI::StructByReference
- FFI::StructByValue
- FFI::StructGenerator
- FFI::StructGenerator::Field
- FFI::StructLayout
- FFI::StructLayout::Array
- FFI::StructLayout::Enum
- FFI::StructLayout::Field
- FFI::StructLayout::Function
- FFI::StructLayout::InnerStruct
- FFI::StructLayout::Mapped
- FFI::StructLayout::Number
- FFI::StructLayout::Pointer
- FFI::StructLayout::String
- FFI::StructLayoutBuilder
- FFI::Type
- FFI::Type::Builtin
- FFI::TypesGenerator
- FFI::Union
- FFI::VariadicInvoker

No matching classes.

# FFI::Enums

An instance of this class permits to manage {Enum}s. In fact, Enums is a collection of {Enum}s.

### Public Class Methods

new() click to toggle source

@return [nil]

    # File lib/ffi/enum.rb, line 28
    def initialize
      @all_enums = Array.new
      @tagged_enums = Hash.new
      @symbol_map = Hash.new
    end

### Public Instance Methods

<<(enum) click to toggle source

@param [Enum] enum Add an {Enum} to the collection.

    # File lib/ffi/enum.rb, line 36
    def <<(enum)
      @all_enums << enum
      @tagged_enums[enum.tag] = enum unless enum.tag.nil?
      @symbol_map.merge!(enum.symbol_map)
    end

__map_symbol(symbol) click to toggle source

@param symbol a symbol to find in merge symbol maps of all enums. @return a symbol

    # File lib/ffi/enum.rb, line 55
    def __map_symbol(symbol)
      @symbol_map[symbol]
    end

find(query) click to toggle source

@param query enum tag or part of an enum name @return [Enum] Find a {Enum} in collection.

    # File lib/ffi/enum.rb, line 45
    def find(query)
      if @tagged_enums.has_key?(query)
        @tagged_enums[query]
      else
        @all_enums.detect { |enum| enum.symbols.include?(query) }
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.