Class: Flann::InitializableStruct

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/flann.rb

Direct Known Subclasses

Parameters

Instance Method Summary collapse

Constructor Details

#initialize(pointer = nil, *layout, &block) ⇒ InitializableStruct

Returns a new instance of InitializableStruct.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/flann.rb', line 56

def initialize pointer=nil, *layout, &block
  if pointer.respond_to?(:each_pair)
    options = pointer
    pointer = nil
  else
    options
  end

  super(pointer, *layout, &block)

  if defined?(self.class::DEFAULTS)
    options = self.class::DEFAULTS.merge(options)
  end

  options.each_pair do |key, value|
    self[key] = value
  end unless options.nil?
end