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
38 def all?(object = default = true, operator = :===, &block)
39   super(&_block_for_all_any_extended(object, default, operator, &block))
40 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
49 def any?(object = default = true, operator = :===, &block)
50   super(&_block_for_all_any_extended(object, default, operator, &block))
51 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
56 def _block_for_all_any_extended(object, default, operator, &block)
57   default ? block : begin
58     raise ::ArgumentError, 'both block and object argument given', caller(1) if block
59     lambda { |*a| object.send(operator, *a) }
60   end
61 end