Class: FFI::Enums

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

Instance Method Summary collapse

Constructor Details

#initializeEnums

Returns a new instance of Enums.



5
6
7
8
9
# File 'lib/ffi/enum.rb', line 5

def initialize
  @all_enums = Array.new
  @tagged_enums = Hash.new
  @symbol_map = Hash.new
end

Instance Method Details

#<<(enum) ⇒ Object



11
12
13
14
15
# File 'lib/ffi/enum.rb', line 11

def <<(enum)
  @all_enums << enum
  @tagged_enums[enum.tag] = enum unless enum.tag.nil?
  @symbol_map.merge!(enum.symbol_map)
end

#__map_symbol(symbol) ⇒ Object



25
26
27
# File 'lib/ffi/enum.rb', line 25

def __map_symbol(symbol)
  @symbol_map[symbol]
end

#find(query) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/ffi/enum.rb', line 17

def find(query)
  if @tagged_enums.has_key?(query)
    @tagged_enums[query]
  else
    @all_enums.detect { |enum| enum.symbols.include?(query) }
  end
end