Module:IP/doc: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
start documenting the IPv4Collection class
(fix two glitches: subnets 1.2.3.0/24 and 1.2.0.0/16 are not equal (can't think of a better replacement); subnet 1.2.4.0/16 is invalid)
(start documenting the IPv4Collection class)
Line 1:
Module:IP is a library for working with IP addresses and subnets. It can handle both [[IPv4]] and [[IPv6]]. The library exports twofour classes, [[#IPAddress|IPAddress]] and, [[#Subnet|Subnet]], [[#IPv4Collection|IPv4Collection]], and [[#IPv6Collection]].
 
== Loading the library ==
Line 376:
-- 192.168.0.2
-- 192.168.0.3
</source>
 
== IPv4Collection ==
 
The IPv4Collection class is used to work with several different IPv4 addresses and IPv4 subnets. To create a new IPv4Collection object:
 
<source lang="lua">
local collection = IPv4Collection.new()
</source>
 
IPv4Collection objects have several methods, outlined below.
 
=== getVersion ===
 
<source lang="lua">
collection:getVersion()
</source>
 
Returns the string "IPv4".
 
=== addIP ===
 
<source lang="lua">
collection:addIP(ip)
</source>
 
Adds an IP to the collection. The IP can be either a string or an [[#IPAddress|IPAddress]] object.
 
Examples:
 
<source lang="lua">
collection:addIP('1.2.3.4')
collection:addIP(IPAddress.new('1.2.3.4'))
</source>
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu