Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Addrinfo#ip_address

addrinfo.ip_address => string

Returns the IP address as a string.

Example
Addrinfo.tcp("127.0.0.1", 80).ip_address    #=> "127.0.0.1"
Addrinfo.tcp("::1", 80).ip_address          #=> "::1"
See also #ip? #ip_port #inspect_sockaddr #ip_unpack also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0