Module: Enumerable

Included in:
Homebrew::Style::Offenses, Options, PATH, Tap
Defined in:
extend/enumerable.rb

Instance Method Summary collapse

Instance Method Details

#compact_blankT.self_type

Returns a new +Array+ without the blank items. Uses Object#blank? for determining if an item is blank.

[1, “”, nil, 2, “ “, [], {}, false, true].compact_blank # => [1, 2, true]

Set.new([nil, “”, 1, false]).compact_blank # => [1]

When called on a +Hash+, returns a new +Hash+ without the blank values.

{ a: “”, b: 1, c: nil, d: [], e: false, f: true }.compact_blank # => { b: 1, f: true }

Returns:

  • (T.self_type)


24
# File 'extend/enumerable.rb', line 24

def compact_blank = T.unsafe(self).reject(&:blank?)

#exclude?(object) ⇒ Boolean

The negative of the Enumerable#include?. Returns +true+ if the collection does not include the object.

Parameters:

  • object (T.untyped)

Returns:

  • (Boolean)


8
# File 'extend/enumerable.rb', line 8

def exclude?(object) = !include?(object)