Module: LinuxStat::Net
- Defined in:
- lib/linux_stat/net.rb
Class Method Summary collapse
-
.ipv4_private ⇒ Object
Returns the local IP address of the system as a String.
Class Method Details
.ipv4_private ⇒ Object
Returns the local IP address of the system as a String. If the information isn’t available, it will a frozen empty string.
6 7 8 9 10 |
# File 'lib/linux_stat/net.rb', line 6 def ipv4_private require 'socket' ip = Socket.ip_address_list.find(&:ipv4_private?) ip ? ip.ip? ? ip.ip_unpack[0].freeze : ''.freeze : ''.freeze end |