module Nuggets::Enumerable::AllAnyExtendedMixin

Public Instance Methods

all?(obj[, operator]) → +true+ or +false+ click to toggle source
all? { ... } → +true+ or +false+

Adds the ability to pass an object instead of a block, which will then be tested against each item in enum according to operator, defaulting to :===.

Calls superclass method
# File lib/nuggets/enumerable/all_any_extended_mixin.rb, line 38
def all?(object = default = true, operator = :===, &block)
  super(&_block_for_all_any_extended(object, default, operator, &block))
end
any?(obj[, operator]) → +true+ or +false+ click to toggle source
any? { ... } → +true+ or +false+

Adds the ability to pass an object instead of a block, which will then be tested against each item in enum according to operator, defaulting to :===.

Calls superclass method
# File lib/nuggets/enumerable/all_any_extended_mixin.rb, line 49
def any?(object = default = true, operator = :===, &block)
  super(&_block_for_all_any_extended(object, default, operator, &block))
end

Private Instance Methods

_block_for_all_any_extended(object, default, operator, &block) click to toggle source

Common argument processing for extended versions of all? and any?.

# File lib/nuggets/enumerable/all_any_extended_mixin.rb, line 56
def _block_for_all_any_extended(object, default, operator, &block)
  default ? block : begin
    raise ::ArgumentError, 'both block and object argument given', caller(1) if block
    lambda { |*a| object.send(operator, *a) }
  end
end