ローカル IP アドレスを取得する方法
require "socket"
Socket.getaddrinfo(
Socket::gethostname,
nil,
Socket::AF_INET,
nil,
Socket::IPPROTO_TCP
)
参考:
singleton method Socket.getaddrinfo (Ruby 2.5.0)
ホスト名を取得する
参考:
Ruby のプロセスが稼働しているサーバの hostname を取得する – Qiita
singleton method Socket.gethostname (Ruby 2.5.0)
ホスト名からアドレスを取得する
参考: