From 1df3b14bdfd26470c007b8443979cd20df0ea649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Mon, 17 Feb 2020 18:46:33 +0000 Subject: document :family() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Asbjørn Sloth Tønnesen --- README.rst | 8 ++++++++ lua/inet/core.lua | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index c7c0b0e..5779b0a 100644 --- a/README.rst +++ b/README.rst @@ -84,6 +84,7 @@ Operator Description ``:flip()`` flip the least significant network bit ``:bits()`` return the address bits in a table ``:subnets()`` return the amount of /n subnets +``:family()`` return the address family (number) ================= ====================================== @@ -416,6 +417,13 @@ Valid values for ``n`` are ``1``, ``2``, ``4``, ``8``, ``16`` or ``32``. inet('2001:db8::/48'):subnets(64) -- returns 65536 inet('2001:db8::/64'):subnets(56) -- returns 0.00390625 +``foo:family(n)`` +~~~~~~~~~~~~~~~~~ + +:: + + inet('192.0.2.0/24'):family() -- returns 4 + inet('2001:db8::/64'):family() -- returns 6 Sets ---- diff --git a/lua/inet/core.lua b/lua/inet/core.lua index 5008da9..398bc66 100644 --- a/lua/inet/core.lua +++ b/lua/inet/core.lua @@ -71,7 +71,8 @@ end function inet:family() local mt = assert(getmetatable(self)) - return assert(mt2fam[mt]) + local ret = assert(mt2fam[mt]) + return ret end local ipv4_parser -- cgit v1.2.1