Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/phidgets-ffi/ffi/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#to_varargsObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/phidgets-ffi/ffi/core_ext.rb', line 2

def to_varargs
  return nil if empty?
  self.map { |a|
    case
    when a.kind_of?(String)
      [:string, a]
    when a.kind_of?(Fixnum)
      [:long_long, a]
    when a.kind_of?(Float)
      [:double, a]
    else
      raise Phidgets::FFI::Error, "Unsupported vararg type: #{a.class}"
    end
  }.flatten
end