Anonymous user
Module:IP: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
tweak IPRange structure
(create outline of a library for dealing with IP addresses) |
(tweak IPRange structure) |
||
Line 60:
local IPRange = {}
function IPRange.new(
-- Set up structure
local mt = {}
local obj = setmetatable({}, mt)
-- Private methods
local function parseIPRange(range)
return '1.2.3.4', '5.6.7.8'
▲ local version = 4
end
-- Public methods
function obj:getRange()
return tostring(self)
end
function obj:setRange(first, last)
if last then
data.startIP = first
data.endIP = last
else
data.startIP, data.endIP = parseIPRange(first)
end
end
function obj:getStartIP()
return
end
function obj:setStartIP(ip)
end
function obj:getEndIP()
return
end
function obj:setEndIP(ip)
end
Line 107 ⟶ 124:
return normalizedIP
end
-- Set initial values
if not first then
error('no range specified', 2)
end
obj:setRange(first, last)
data.version = 4
return obj
|