Module:IP: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
mt variable not needed for Subnet; this is similar to IPAddress
(add __concat metamethod for Subnet)
(mt variable not needed for Subnet; this is similar to IPAddress)
Line 489:
-- is a Subnet object.
local uniqueKey = {}
 
-- Metatable
local mt = {
__eq = function (self, obj)
return self:getCIDR() == obj:getCIDR()
end,
__concat = function (self, obj)
return tostring(self) .. tostring(obj)
end,
__tostring = function (self)
return self:getCIDR()
end,
__metatable = uniqueKey
}
 
-- Private static methods
Line 520 ⟶ 506:
makeSubnetFromRaw = function (rawIP, bitLength)
-- Set up structure
local obj = setmetatable({}, mt){
__eq = function (self, obj)
return self:getCIDR() == obj:getCIDR()
end,
__concat = function (self, obj)
return tostring(self) .. tostring(obj)
end,
__tostring = function (self)
return self:getCIDR()
end,
__metatable = uniqueKey,
})
local data = {
rawIP = rawIP,
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu