Anonymous user
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 = {}
__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({},
▲ __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,
|