From e1b6823b7c8daf5a6742ab41cc9bdc585c994bf8 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sun, 18 Jul 2010 21:00:27 +0800 Subject: Create an Hash#key alias for Hash#index (Ruby < 1.9) --- lib/ipaddress/extensions/extensions.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/ipaddress/extensions/extensions.rb b/lib/ipaddress/extensions/extensions.rb index 0d70bda..a474e18 100644 --- a/lib/ipaddress/extensions/extensions.rb +++ b/lib/ipaddress/extensions/extensions.rb @@ -2,6 +2,12 @@ class << Math def log2(n); log(n) / log(2); end end +if RUBY_VERSION =~ /1\.8/ + class Hash + alias :key :index + end +end + class Integer def power_of_2? Math::log2(self).to_i == Math::log2(self) -- cgit v1.2.1