Class: Dumper::Utility::IP

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/dumper/utility/ip.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ IP

Returns a new instance of IP.



10
11
12
13
14
15
16
17
# File 'lib/dumper/utility/ip.rb', line 10

def initialize(*args)
  UDPSocket.open do |s|
    s.do_not_reverse_lookup = true
    s.connect '64.233.187.99', 1
    @ip = IPAddress(s.addr.last)
  end
  raise "#{@ip.address} is not IPv4!" unless @ip.ipv4?
end