Method: IPAddress.ntoa
- Defined in:
- lib/ipaddress.rb
.ntoa(uint) ⇒ Object
Converts a unit32 to IPv4
IPAddress::ntoa(167837953)
#-> "10.1.1.1"
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ipaddress.rb', line 69 def self.ntoa(uint) unless(uint.is_a? Numeric and uint <= 0xffffffff and uint >= 0) raise(::ArgumentError, "not a long integer: #{uint.inspect}") end ret = [] 4.times do ret.unshift(uint & 0xff) uint >>= 8 end ret.join('.') end |