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
Class Method Summary collapse
-
.max_one(array) ⇒ Object?
private
Return only element in array if it contains max one member.
-
.one(array) ⇒ Object
private
Return only element in array if it contains exactly one member.
Class Method Details
.max_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 max one member
rubocop:disable Lint/EmptyInPattern
23 24 25 26 27 28 29 30 31 |
# File 'lib/mutant/util.rb', line 23 def self.max_one(array) case array in [] in [value] value else fail Unparser::Util::SizeError, "expected size to be max 1 but size was #{array.size}" end end |
.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
11 12 13 |
# File 'lib/mutant/util.rb', line 11 def self.one(array) Unparser::Util.one(array) end |