Method: LIBUSB::Context#set_option

Defined in:
lib/libusb/context.rb

#set_option(option, *args) ⇒ Object

Set a context related libusb option from the option list.

Parameters:

  • Zero or more arguments depending on option

See Also:



215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/libusb/context.rb', line 215

def set_option(option, *args)
  if Call.respond_to?(:libusb_set_option)
    # Available since libusb-1.0.22
    ffi_args = LIBUSB.send(:option_args_to_ffi, option, args, self)
    res = Call.libusb_set_option(@ctx, option, *ffi_args)
    LIBUSB.raise_error res, "in libusb_set_option" if res<0

  else
    # Fallback to deprecated function, if the gem is linked to an older libusb.

    raise ArgumentError, "unknown option #{option.inspect}" unless [:OPTION_LOG_LEVEL, LIBUSB::OPTION_LOG_LEVEL].include?(option)
    Call.libusb_set_debug(@ctx, *args)
  end
end