Module: Refinements::Shared::Many

Defined in:
lib/refinements/shared/many.rb

Overview

Provides functionality for knowing whether an enumerable has many elements or not.

Instance Method Summary collapse

Instance Method Details

#many?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
# File 'lib/refinements/shared/many.rb', line 7

def many?
  return size > 1 unless block_given?

  total = reduce(0) { |count, item| yield(item) ? count + 1 : count }
  total > 1
end