Class: Netchk::IpVerifier

Inherits:
Object
  • Object
show all
Defined in:
lib/netchk/ip_verifier.rb

Instance Method Summary collapse

Instance Method Details

#verifyObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/netchk/ip_verifier.rb', line 6

def verify
  socket = Socket.ip_address_list
  addresses = socket.reject(&:ipv4_loopback?)
  addresses.reject!(&:ipv6_loopback?)
  addresses.filter!(&:ipv4?)
  addresses.map!(&:inspect_sockaddr)

  if addresses.empty?
    $stderr.puts 'No IPv4 address found. Verify your connection to your router.'
  else
    puts "Found IP addresses #{addresses.join(', ')}."
  end
end