Ruby IPAddr Functions

EditRocket provides the following information on IPAddr functions in the Ruby source code builder.

hton() - Returns a network byte ordered string form of the IP address.

include?(other) - Returns true if the given ipaddr is in the range.

inspect() - "Returns a string containing a human-readable representation of the ipaddr. ("#<IPAddr: family:address/mask>")"

ip6_arpa() - Returns a string for DNS reverse lookup compatible with RFC3172.

ip6_int() - Returns a string for DNS reverse lookup compatible with RFC1886.

ipv4?() - Returns true if the ipaddr is an IPv4 address.

ipv4_compat?() - Returns true if the ipaddr is an IPv4-compatible IPv6 address.

ipv4_compat() - Returns a new ipaddr built by converting the native IPv4 address into an IPv4-compatible IPv6 address.

ipv4_mapped?() - Returns true if the ipaddr is an IPv4-mapped IPv6 address.

ipv4_mapped() - Returns a new ipaddr built by converting the native IPv4 address into an IPv4-mapped IPv6 address.

ipv6?() - Returns true if the ipaddr is an IPv6 address.

mask(prefixlen) - Returns a new ipaddr built by masking IP address with the given prefixlen/netmask. (e.g. 8, 64, "255.255.255.0", etc.)

native() - Returns a new ipaddr built by converting the IPv6 address into a native IPv4 address. If the IP address is not an IPv4-mapped or IPv4-compatible IPv6 address, returns self.

new(addr = '::', family = Socket::AF_UNSPEC) - Creates a new ipaddr containing the given human readable form of an IP address. It also accepts `address/prefixlen' and `address/mask'. When prefixlen or mask is specified, it returns a masked ipaddr. IPv6 address may beenclosed with `[' and `]'.

new_ntoh(addr) - Creates a new ipaddr containing the given network byte ordered string form of an IP address.

ntop(addr) - Convert a network byte ordered string form of an IP address into human readable form.

reverse() - Returns a string for DNS reverse lookup. It returns a string in RFC3172 form for an IPv6 address.

to_i() - Returns the integer representation of the ipaddr.

to_s() - Returns a string containing the IP address representation.

to_string() - Returns a string containing the IP address representation in canonical form.