--	iMRoyMdEWA2FQBJFpVm
Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature";
	boundary-byyM+bFcwYHV1sWC1M9G"


--yyM+bFcwYHV1sWC1M9G
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Wed, 2007-09-12 at 02:57 +0900, Nikolay Pavlov wrote:
> Hallo all.
> Of course i am reinventing the wheel, but may be that would be helpful for 
> some one. With this method you can replace a key with a new one in a Hash.
> It could be helpful for example if you want to parse a lot of XML documents 
> in hash from various external sources in one Library, so that you can 
> handle a unified interface.  
> 
> class Hash
> 
>   # Replace an old key with a new one
>   #
>   # === Arguments:
>   # * old_key
>   # * new_key
>   def alter_key(old_key, new_key)
>     raise IndexError.new("key already exist") if self[new_key]
>     if self.has_key?(old_key)
>       self[new_key] = self[old_key]
>       self.delete(old_key)
>     end
>     return self
>   end
> end

It can even be written more concisely as:

  class Hash 
    def alter_key(old_key, new_key)
      raise IndexError, 'key already exists' if has_key? new_key
      store(new_key, delete(old_key)) if has_key? old_key
      return self
    end
  end


Cheers,
Daniel Schierbeck

--yyM+bFcwYHV1sWC1M9G
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: quoted-printable

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQBG5tsLE8pU4Gwf6g8RAvhlAJ9kHjYkMmSAS7UI+tJx+45XyZR4zACgjhAb
XcYttSvUl+vYpYlA2f/qiAM=
=vl9P
-----END PGP SIGNATURE-----

--yyM+bFcwYHV1sWC1M9G--

--	iMRoyMdEWA2FQBJFpVm
Content-Type: application/x-pkcs7-signature; name=smime.p7s
Content-Disposition: attachment; filename=smime.p7s
Content-Transfer-Encoding: base64

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIILGjCCBYkw
ggRxoAMCAQICBEOI1E4wDQYJKoZIhvcNAQEFBQAwMTELMAk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