Nicht angemeldeter Benutzer - Bearbeiten von Seiten ist nur als angemeldeter Benutzer möglich.

Änderungen

Zur Navigation springen Zur Suche springen
73 Bytes entfernt ,  04:48, 6. Mär. 2013
Modify to return object instead of table (convention, works with unit test framework)
Zeile 5: Zeile 5:  
]]
 
]]
   −
function isIpV6( s )
+
function _isIpV6( s )
 
     local dcolon, groups
 
     local dcolon, groups
 
     if type( s ) ~= "string"
 
     if type( s ) ~= "string"
Zeile 24: Zeile 24:  
end
 
end
   −
function isIpV4( s )
+
function _isIpV4( s )
 
     local function legal( n ) return ( tonumber( n ) or 256 ) < 256  end-- in lua 0 is true!
 
     local function legal( n ) return ( tonumber( n ) or 256 ) < 256  end-- in lua 0 is true!
 
      
 
      
Zeile 32: Zeile 32:  
end
 
end
   −
function isIp( s )
+
function _isIp( s )
 
     return isIpV4( s ) and "4" or isIpV6( s ) and "6"
 
     return isIpV4( s ) and "4" or isIpV6( s ) and "6"
 
end
 
end
   −
-- return a table to allow the functions to be called from templates
+
local p = {}
return {
+
 
    ["isIpV6"] = function( frame ) return isIpV6( frame.args[ 1 ] ) and "1" or "0" end,
+
function p.isIpV6(frame) return _isIpV6( frame.args[ 1 ] ) and "1" or "0" end
    ["isIpV4"] = function( frame ) return isIpV4( frame.args[ 1 ] ) and "1" or "0" end,
+
function p.isIpV4(frame) return _isIpV4( frame.args[ 1 ] ) and "1" or "0" end
    ["isIp"] = function( frame ) return isIp( frame.args[ 1 ] ) or "" end
+
function p.isIp(frame) return _isIp( frame.args[ 1 ] ) and "1" or "0" end
}
+
 
 +
return p
Anonymer Benutzer
Cookies helfen uns bei der Bereitstellung von imedwiki. Durch die Nutzung von imedwiki erklärst du dich damit einverstanden, dass wir Cookies speichern.

Navigationsmenü