Module | IPAddress |
In: |
lib/ipaddress/ipv4.rb
lib/ipaddress/ipv6.rb lib/ipaddress/prefix.rb lib/ipaddress.rb |
NAME | = | "IPAddress" |
GEM | = | "ipaddress" |
AUTHORS | = | ["Marco Ceresa <ceresa@ieee.org>"] |
Parse the argument string to create a new IPv4, IPv6 or Mapped IP object
ip = IPAddress.parse "172.16.10.1/24" ip6 = IPAddress.parse "2001:db8::8:800:200c:417a/64" ip_mapped = IPAddress.parse "::ffff:172.16.10.1/128"
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
Checks if the given string is a valid IPv4 address
Example:
IPAddress::valid_ipv4? "2002::1" #=> false IPAddress::valid_ipv4? "172.16.10.1" #=> true
Checks if the argument is a valid IPv4 netmask expressed in dotted decimal format.
IPAddress.valid_ipv4_netmask? "255.255.0.0" #=> true
Checks if the given string is a valid IPv6 address
Example:
IPAddress::valid_ipv6? "2002::1" #=> true IPAddress::valid_ipv6? "2002::DEAD::BEEF" #=> false