def get_device(vendor_id, product_id, serial_number = nil, options = {})
      raise ArgumentError, 'vendor_id must be provided' if vendor_id.to_i == 0
      raise ArgumentError, 'product_id must be provided' if product_id.to_i == 0

      if serial_number.is_a?(Hash)
        options = serial_number
        serial_number = nil
      end

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

      list = enumerate(vendor_id, product_id, as: :no_mapping)
      return nil unless list && list.count > 0
      if serial_number.to_s == ''
        if klass != :no_mapping
          return klass.new(list.first)
        else
          return list.first
        end
      end
      list.each do |dev|
        if dev.serial_number == serial_number
          if klass != :no_mapping
            return klass.new(dev)
          else
            return dev
          end
        end
      end
      nil
    end
def get_device(vendor_id, product_id, serial_number = nil, options = {})
      raise ArgumentError, 'vendor_id must be provided' if vendor_id.to_i == 0
      raise ArgumentError, 'product_id must be provided' if product_id.to_i == 0

      if serial_number.is_a?(Hash)
        options = serial_number
        serial_number = nil
      end

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

      list = enumerate(vendor_id, product_id, as: :no_mapping)
      return nil unless list && list.count > 0
      if serial_number.to_s == ''
        if klass != :no_mapping
          return klass.new(list.first)
        else
          return list.first
        end
      end
      list.each do |dev|
        if dev.serial_number == serial_number
          if klass != :no_mapping
            return klass.new(dev)
          else
            return dev
          end
        end
      end
      nil
    end
Gets the first device with the specified vendor_id, product_id, and optionally serial_number.