Module: Treequel::ArrayUtilities

Defined in:
lib/treequel/mixins.rb

Overview

A collection of utilities for working with Arrays.

Class Method Summary collapse

Class Method Details

.stringify_array(array) ⇒ Object

Return a version of the given array with any Symbols contained in it turned into Strings.



258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/treequel/mixins.rb', line 258

def stringify_array( array )
	return array.collect do |item|
		case item
		when Symbol
			item.to_s
		when Array
			stringify_array( item )
		else
			item
		end
	end
end

.symbolify_array(array) ⇒ Object

Return a version of the given array with any Strings contained in it turned into Symbols.



274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/treequel/mixins.rb', line 274

def symbolify_array( array )
	return array.collect do |item|
		case item
		when String
			item.to_sym
		when Array
			symbolify_array( item )
		else
			item
		end
	end
end