Module: Mutant::Util Private
- Defined in:
- lib/mutant/util.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Utility methods
Constant Summary collapse
- SizeError =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Error raised by ‘Util.one` if size is less than zero or greater than one
Class.new(IndexError)
Class Method Summary collapse
-
.one(array) ⇒ Object
private
Return only element in array if it contains exactly one member.
Class Method Details
.one(array) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return only element in array if it contains exactly one member
14 15 16 17 18 |
# File 'lib/mutant/util.rb', line 14 def self.one(array) return array.first if array.one? fail SizeError, "expected size to be exactly 1 but size was #{array.size}" end |