Sha256: 4aab6a7afe9f6aeeb3f6dfb152acad843fdd5fb64bfe50ea1a8f83cee6ff3140

Contents?: true

Size: 455 Bytes

Versions: 2

Compression:

Stored size: 455 Bytes

Contents

Dumper::Dependency.load('ipaddress')
require 'forwardable'

module Dumper
  module Utility
    class IP
      extend Forwardable
      def_delegators :@ip, :address, :private?

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dumper-1.7.3 lib/dumper/utility/ip.rb
dumper-1.7.2 lib/dumper/utility/ip.rb