Class: Array

Inherits:
Object show all
Defined in:
lib/libis/tools/extend/array.rb

Overview

Extension class for Array

Instance Method Summary collapse

Instance Method Details

#cleanupObject

Removes all empty entries



6
7
8
# File 'lib/libis/tools/extend/array.rb', line 6

def cleanup
  self.delete_if { |v| v.nil? || (v.respond_to?(:empty?) ? v.empty? : false) }
end

#recursive_cleanupObject

Removes all empty entries recursively in the array and each Hash in it



11
12
13
14
# File 'lib/libis/tools/extend/array.rb', line 11

def recursive_cleanup
  each { |v| v.recursive_cleanup if Array === v || Hash === v }
  cleanup
end