Sha256: b585145821eb4adf8b02684b49bcf0ff8ece6c9f5ec6aae04452431a96d66681

Contents?: true

Size: 485 Bytes

Versions: 3

Compression:

Stored size: 485 Bytes

Contents

class Hash
	# A simple little routine to downcase any String used as a key
	# in a hash or any hash nested as value somewhere within the hash.
	# Thanks to Daniel Berger for this implementation.

	def downcase_keys!
		upper = /A-Z/
		self.each do |k,v|
			next unless k.kind_of? String
			self[k.dup.downcase] = v
			self.delete(k) if upper.match(k)
		end
	end

	def stringify_keys!
		self.each do |k,v|
			next if k.kind_of? String
			self[k.to_s] = v
			self.delete k
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
IOWA-1.0.3 src/iowa/Extensions/Hash.rb
IOWA-1.0.2 src/iowa/Extensions/Hash.rb
IOWA-1.0.0 src/iowa/Extensions/Hash.rb