Class: FFI::Enums
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/ffi/enum.rb |
Overview
Class Method Summary
- .new ⇒ Enums constructor
Instance Method Summary
-
#<<(enum)
Add an
Enum
to the collection. - #__map_symbol(symbol) ⇒ Object
-
#find(query) ⇒ Enum
Find a
Enum
in collection.
Constructor Details
.new ⇒ Enums
# File 'lib/ffi/enum.rb', line 38
def initialize @all_enums = Array.new @tagged_enums = Hash.new @symbol_map = Hash.new end
Instance Method Details
#<<(enum)
Add an Enum
to the collection.
# File 'lib/ffi/enum.rb', line 46
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
# File 'lib/ffi/enum.rb', line 65
def __map_symbol(symbol) @symbol_map[symbol] end
#find(query) ⇒ Enum
Find a Enum
in collection.
# File 'lib/ffi/enum.rb', line 55
def find(query) if @tagged_enums.has_key?(query) @tagged_enums[query] else @all_enums.detect { |enum| enum.symbols.include?(query) } end end