lib/hidapi/engine.rb
def enumerate(vendor_id = 0, product_id = 0, options = {})
      raise HIDAPI::HidApiError, 'not initialized' unless @context

      if vendor_id.is_a?(Hash) || (vendor_id.is_a?(String) && options.empty?)
        options = vendor_id
        vendor_id = 0
        product_id = 0
      end

      if product_id.is_a?(Hash) || (product_id.is_a?(String) && options.empty?)
        options = product_id
        product_id = 0
      end

      if options.is_a?(String) || options.is_a?(Symbol)
        options = { as: options }
      end

      unless options.nil? || options.is_a?(Hash)
        raise ArgumentError, 'options hash is invalid'
      end

      klass = (options || {}).delete(:as) || 'HIDAPI::Device'
      klass = Object.const_get(klass) unless klass == :no_mapping

      filters = { bClass: HID_CLASS }

      unless vendor_id.nil? || vendor_id.to_i == 0
        filters[:idVendor] = vendor_id.to_i
      end
      unless product_id.nil? || product_id.to_i == 0
        filters[:idProduct] = product_id.to_i
      end

      list = @context.devices(filters)

      if klass != :no_mapping
        list.to_a.map{ |dev| klass.new(dev) }
      else
        list.to_a
      end
    end
def enumerate(vendor_id = 0, product_id = 0, options = {})
      raise HIDAPI::HidApiError, 'not initialized' unless @context

      if vendor_id.is_a?(Hash) || (vendor_id.is_a?(String) && options.empty?)
        options = vendor_id
        vendor_id = 0
        product_id = 0
      end

      if product_id.is_a?(Hash) || (product_id.is_a?(String) && options.empty?)
        options = product_id
        product_id = 0
      end

      if options.is_a?(String) || options.is_a?(Symbol)
        options = { as: options }
      end

      unless options.nil? || options.is_a?(Hash)
        raise ArgumentError, 'options hash is invalid'
      end

      klass = (options || {}).delete(:as) || 'HIDAPI::Device'
      klass = Object.const_get(klass) unless klass == :no_mapping

      filters = { bClass: HID_CLASS }

      unless vendor_id.nil? || vendor_id.to_i == 0
        filters[:idVendor] = vendor_id.to_i
      end
      unless product_id.nil? || product_id.to_i == 0
        filters[:idProduct] = product_id.to_i
      end

      list = @context.devices(filters)

      if klass != :no_mapping
        list.to_a.map{ |dev| klass.new(dev) }
      else
        list.to_a
      end
    end
Creates a new engine.

 Enumerates the HID devices matching the vendor and product IDs.

 Both vendor_id and product_id are optional.  They will act as a wild card if set to 0 (the default).