Sha256: 41f4660fd5a98eb7ad192ea6835c7096a3199f75a62d9154205bc84fda3aaf15
Contents?: true
Size: 481 Bytes
Versions: 47
Compression:
Stored size: 481 Bytes
Contents
# frozen_string_literal: true module RuboCop module RSpec # 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 def one(array) return array.first if array.one? raise SizeError, "expected size to be exactly 1 but size was #{array.size}" end end end end
Version data entries
47 entries across 47 versions & 1 rubygems