Sha256: b610d0d9256cbb3565f8930ab36a0b283b5bfd3a160159e923db15ba6c8469e6
Contents?: true
Size: 519 Bytes
Versions: 93
Compression:
Stored size: 519 Bytes
Contents
# frozen_string_literal: true module Mutant # Utility methods module Util # Error raised by `Util.one` if size is less than zero or greater than one SizeError = Class.new(IndexError) # Return only element in array if it contains exactly one member # # @param array [Array] # # @return [Object] first entry def self.one(array) return array.first if array.one? fail SizeError, "expected size to be exactly 1 but size was #{array.size}" end end # Util end # Mutant
Version data entries
93 entries across 93 versions & 1 rubygems