Method: Wgit::Utils.sanitize_arr

Defined in:
lib/wgit/utils.rb

.sanitize_arr(arr, encode: true) ⇒ Enumerable

Sanitises an Array to make it uniform. Removes empty Strings and nils, processes non empty Strings using Wgit::Utils.sanitize and removes duplicates.

Parameters:

  • The Array to sanitize. arr is not modified.

Returns:

  • The sanitized arr.



290
291
292
293
294
295
296
297
298
# File 'lib/wgit/utils.rb', line 290

def self.sanitize_arr(arr, encode: true)
  return arr unless arr.is_a?(Array)

  arr
    .map { |str| sanitize(str, encode:) }
    .reject { |str| str.is_a?(String) && str.empty? }
    .compact
    .uniq
end