Sha256: 6017c96f97e817716e5a9b30a0ca598ab747f645d0eed6415b048e3dd972139a

Contents?: true

Size: 551 Bytes

Versions: 5

Compression:

Stored size: 551 Bytes

Contents

class Hash

  def method_missing(id)
      to_hash[id.id2name]
  end
  
  # takes an array of keys and returns an array of values
  # it would really be ideal to extend the definition of []
  def find_multiple_key_values(array)
    return [self[array]] unless array.is_a? Array
    array.collect { |k| self[k] }
  end

	def inspect
		a = keys.collect { |key| n = (key.respond_to?(:to_s)) ? key.to_s : nil; [key, n] }.sort { |l, r| l[1] <=> r[1] }
		"{" + a.collect { |(key, junk)| key.inspect + "=>" + self[key].inspect }.join(", ") + "}"
	end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
smklib-1.2.0 lib/smklib/hash_ext.rb
smklib-1.1.2 lib/smklib/hash_ext.rb
smklib-1.1.1 lib/smklib/hash_ext.rb
smklib-1.1.0 lib/smklib/hash_ext.rb
smklib-1.0.6 lib/smklib/hash_ext.rb