Arborist::

NetworkUtilities

module

A collection of utilities for working with network addresses, names, etc.

Constants

IPADDR_RE

A union of IPv4 and IPv6 regular expressions.

Public Instance Methods

anchor
normalize_address( address )

Return the specified address as one or more IPAddr objects.

# File lib/arborist/mixins.rb, line 405
def normalize_address( address )
        addresses = []
        case address
        when IPAddr
                addresses << address
        when IPADDR_RE
                addresses << IPAddr.new( address )
        when String
                ip_addr = TCPSocket.gethostbyname( address )
                addresses = ip_addr[3..-1].map{|ip| IPAddr.new(ip) }
        else
                raise "I don't know how to parse a %p host address (%p)" %
                        [ address.class, address ]
        end

        return addresses
end