Module: IntIPExtensions
- Defined in:
- lib/ipaddr_extensions.rb
Instance Method Summary collapse
Instance Method Details
#to_ip(af = nil) ⇒ Object
525 526 527 528 529 530 531 532 533 534 535 536 537 538 |
# File 'lib/ipaddr_extensions.rb', line 525 def to_ip(af=nil) if af.nil? ## If there is no address family specified then try to guess... if self.to_i > 0xffffffff # If the integer is bigger than any possible IPv4 address # then presume it's an IPv6 address af = Socket::AF_INET6 else # otherwise presume it's IPv4 af = Socket::AF_INET end end IPAddr.new(self.to_i, af) end |