module LimitDetectors
Constants
- VERSION
Public Instance Methods
at_least(limit, &block)
click to toggle source
Deprecated, use at_least
? instead
# File lib/limit_detectors.rb, line 13 def at_least(limit, &block) Kernel.warn "'at_least' is deprecated, use 'at_least?' instead" at_least? limit, &block end
at_least?(limit, &block)
click to toggle source
Check whether the condition given in the block occurs at least limit times in the collection
# File lib/limit_detectors.rb, line 26 def at_least?(limit, &block) occurrences_of(&block) >= limit end
at_most(limit, &block)
click to toggle source
Deprecated, use at_most
? instead
# File lib/limit_detectors.rb, line 7 def at_most(limit, &block) Kernel.warn "'at_most' is deprecated, use 'at_most?' instead" at_most? limit, &block end
at_most?(limit, &block)
click to toggle source
Check whether the condition given in the block occurs at most limit times in the collection
# File lib/limit_detectors.rb, line 20 def at_most?(limit, &block) occurrences_of(&block) <= limit end
occurrences_of() { |el| ... }
click to toggle source
Count how often the condition given in the block is met for the collection
# File lib/limit_detectors.rb, line 32 def occurrences_of inject(0) do |res, el| res += 1 if yield el res end end