lib/ipaddress.rb in ipaddress-0.7.5 vs lib/ipaddress.rb in ipaddress-0.8.0

- old
+ new

@@ -12,13 +12,11 @@ # #++ require 'ipaddress/ipv4' require 'ipaddress/ipv6' -require 'ipaddress/extensions/extensions' - module IPAddress NAME = "IPAddress" GEM = "ipaddress" AUTHORS = ["Marco Ceresa <ceresa@ieee.org>"] @@ -143,10 +141,13 @@ return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?/ =~ addr && valid_ipv4?($') return true if /\A::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?/ =~ addr && valid_ipv4?($') false end + # + # Deprecate method + # def self.deprecate(message = nil) # :nodoc: message ||= "You are using deprecated behavior which will be removed from the next major or minor release." warn("DEPRECATION WARNING: #{message}") end @@ -183,6 +184,19 @@ # def IPAddress(str) IPAddress::parse str end +# +# Compatibility with Ruby 1.8 +# +if RUBY_VERSION =~ /1\.8/ + class Hash # :nodoc: + alias :key :index + end + module Math # :nodoc: + def Math.log2(n) + log(n) / log(2) + end + end +end