Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/lafcadio/util.rb

Instance Method Summary collapse

Instance Method Details

#onlyObject

If this array has one element, returns that element; otherwise, raises an error.



7
8
9
10
11
12
13
# File 'lib/lafcadio/util.rb', line 7

def only
	if size != 1
		raise "Expected single-value Array but Array has #{ size } members"
	else
		first
	end
end