Sha256: d8675526c0c16e51eed0103bfffc6b27939b50f3d10932468ae43f79ea3f16fd
Contents?: true
Size: 505 Bytes
Versions: 13
Compression:
Stored size: 505 Bytes
Contents
require "socket" class Socket class <<self # pack human-readable address to Socket address # # @example # addr("192.168.1.1") #=> "\xC0\xA8\x01\x01" # # @return [String] address used by Socket # @see unaddr def addr(str) str.split(".").map{|v|v.to_i}.pack("CCCC") end # unpack to humna-readable address from Socket address # # @example # unaddr("\xC0\xA8\x01\x01") #=> "192.168.1.1" # # @return [String] human readable address def unaddr(str) str.unpack("CCCC").join(".") end end end
Version data entries
13 entries across 13 versions & 1 rubygems