Top Level Namespace

Defined Under Namespace

Modules: IPAddress, Math Classes: Hash

Instance Method Summary collapse

Instance Method Details

#IPAddress(str) ⇒ Object

IPAddress is a wrapper method built around IPAddress's library classes. Its purpouse is to make you indipendent from the type of IP address you're going to use.

For example, instead of creating the three types of IP addresses using their own contructors

ip  = ""
ip6 = "2001:db8::8:800:200c:417a/64"
ip_mapped = IPAddress::IPv6::Mapped "::ffff:"

you can just use the IPAddress wrapper:

ip  = IPAddress ""
ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
ip_mapped = IPAddress "::ffff:"

All the object created will be instances of the correct class:

ip.class  #=> IPAddress::IPv4

ip6.class  #=> IPAddress::IPv6

ip_mapped.class  #=> IPAddress::IPv6::Mapped

# File 'lib/ipaddress.rb', line 185

def IPAddress(str)
  IPAddress::parse str