module Enumerable

Public Instance Methods

exclude?(object) click to toggle source

The inverse of Enumerable#include?. Returns true if the collection does not contain object.

# File lib/secret_sauce/core_ext/enumerable.rb, line 7
def exclude? object
  !include? object
end
Also aliased as: excludes?
excludes?(object)
Alias for: exclude?
sum() click to toggle source

Returns the sum of all numeric elements in the collection

[1, 2, 3].sum         # => 6
[[1, 2], [3, 4]].sum  # => 10
{ a: 4, b: 5 }.sum    # => 9
[2, "string", 9].sum  # => 11
# File lib/secret_sauce/core_ext/enumerable.rb, line 18
def sum
  flatten.select { |e| e.is_a? Numeric }.inject(:+) || 0
end