module Doing::ArrayCleanup
Public Instance Methods
Source
# File lib/doing/array/cleanup.rb, line 9 def remove_bad compact.map { |x| x.is_a?(String) ? x.strip : x }.select(&:good?) end
Like Array#compact – removes nil items, but also removes empty strings, zero or negative numbers and FalseClass
items
@return [Array] Array
without “bad” elements
Source
# File lib/doing/array/cleanup.rb, line 13 def remove_bad! replace remove_empty end
Source
# File lib/doing/array/cleanup.rb, line 23 def remove_empty compact.map { |x| x.is_a?(String) ? x.strip : x }.reject { |x| x.is_a?(String) ? x.empty? : false } end
Like Array#compact – removes nil items, but also removes empty elements
@return [Array] Array
without empty elements
Source
# File lib/doing/array/cleanup.rb, line 27 def remove_empty! replace remove_empty end