abstract struct IP::Block
- IP::Block
- Struct
- Value
- Object
Included Modules
- Comparable(IP::Address)
Direct Known Subclasses
Defined in:
ip/block.crip/block.cr
Constructors
-
.[](string : String) : self
Constructs a new
IP::Block
by interpreting the contents of a givenString
. -
.[]?(string : String) : self?
Constructs a new
IP::Block
by interpreting the contents of a givenString
. -
.ipv4(string : String) : self
Constructs a new IPv4
IP::Block
by interpreting the contents of a givenString
. -
.ipv4?(string : String) : self?
Constructs a new IPv4
IP::Block
by interpreting the contents of a givenString
. -
.ipv6(string : String) : self
Constructs a new IPv6
IP::Block
by interpreting the contents of a givenString
. -
.ipv6?(string : String) : self?
Constructs a new IPv6
IP::Block
by interpreting the contents of a givenString
. - .loopback_ipv4 : self
- .loopback_ipv6 : self
-
.new(address : IP::Address, block : Int) : self?
Constructs a new
IP::Block
from an address and block size. -
.new(string : String) : self
Constructs a new
IP::Block
by interpreting the contents of a givenString
. -
.new?(address : IP::Address, block : Int) : self?
Constructs a new
IP::Block
from an address and block size. -
.new?(string : String) : self?
Constructs a new
IP::Block
by interpreting the contents of a givenString
.
Instance Method Summary
-
#<(other : IP::Block)
Compares this block to other returning
true
if the other block falls before the block. -
#<=(other : IP::Block)
Compares this block to other returning
true
if the other block falls before or inside the block. -
#<=>(other : IP::Block) : Int
Compares this block with the other block, returning
-1
,0
or+1
depending if the block is less than, inclusive of, or greater than the other block. -
#<=>(other : IP::Address) : Int
Compares this block with address, returning
-1
,0
or+1
depending if the block is less than, inclusive of, or greater than the other address. -
#==(other : IP::Block)
Compares this block to other returning
true
if the other block is equal to the receiver. -
#>(other : IP::Block)
Compares this block to other returning
true
if the other block falls after the block. -
#>=(other : IP::Block)
Compares this block to other returning
true
if the other block falls after or inside the block. -
#address
Returns the address component of the block which is also the first address.
-
#adjacent?(other : IP::Address) : Bool
Returns a
Bool
indicating if the receiver is 'adjacent' to other. -
#adjacent?(other : IP::Block) : Bool
Returns a
Bool
indicating if the receiver is 'adjacent' to other. -
#block
Returns 'block' size in the form aof 2^x, x being the 'size'.
-
#covers?(other : IP::Address) : Bool
Returns a
Bool
indicating if the receiver 'covers' other. -
#covers?(other : IP::Block) : Bool
Returns a
Bool
indicating if the receiver 'covers' other. -
#each(&block : IP::Address -> Nil) : Nil
Yield each address to the block.
-
#first : IP::Address
Returns the first address in the block.
-
#hash(hasher)
See
Object#hash(hasher)
-
#includes?(other : IP::Address) : Bool
Returns a
Bool
indicating if the receiver 'includes' the other address. -
#inspect(io : IO) : Nil
Appends a type-specified presentation representation of the block to the given
IO
. -
#intersects?(other : IP::Block) : Bool
Returns a
Bool
indicating if the receiver 'intersects' other. -
#intersects?(other : IP::Address) : Bool
Returns a
Bool
indicating if the receiver 'intersects' other. -
#ipv4? : Bool
Informs if the block is IPv4 or not.
-
#ipv6? : Bool
Informs if the block is IPv6 or not.
-
#last : IP::Address
Returns the last address in the block.
-
#mask : IP::Address
Returns the blocks mask.
-
#single_address? : Bool
Informs if the block is a single address or not.
-
#size
Returns the size of the block in terms of number of addresses.
-
#to_s(io : IO) : Nil
Appends the presentation representation of the block to the given
IO
.
Constructor Detail
Constructs a new IP::Block
by interpreting the contents of a given String
.
Expects a definition in CIDR notation similar to [0-255].[0-255].[0-255].[0-255]/[0-32], XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/[0-128], or XXXX:XXXX::XXXX:XXXX:XXXX/[0-128].
Raises: MalformedError
when the input is malformed.
Constructs a new IP::Block
by interpreting the contents of a given String
.
Expects a definition in CIDR notation similar to [0-255].[0-255].[0-255].[0-255]/[0-32], XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/[0-128], or XXXX:XXXX::XXXX:XXXX:XXXX/[0-128].
Returns nil
when the input is malformed.
Constructs a new IPv4 IP::Block
by interpreting the contents of a given String
.
Expects a definition in CIDR notation similar to [0-255].[0-255].[0-255].[0-255]/[0-32].
Raises: MalformedError
when the input is malformed.
Constructs a new IPv4 IP::Block
by interpreting the contents of a given String
.
Expects a definition in CIDR notation similar to [0-255].[0-255].[0-255].[0-255]/[0-32].
Returns nil
when the input is malformed.
Constructs a new IPv6 IP::Block
by interpreting the contents of a given String
.
Expects a definition in CIDR notation similar to XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/[0-128], or XXXX:XXXX::XXXX:XXXX:XXXX/[0-128].
Raises: MalformedError
when the input is malformed.
Constructs a new IPv6 IP::Block
by interpreting the contents of a given String
.
Expects a definition in CIDR notation similar to XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/[0-128], or XXXX:XXXX::XXXX:XXXX:XXXX/[0-128].
Returns nil
when the input is malformed.
Constructs a new IP::Block
from an address and block size.
Raises: MalformedError
when the input is malformed.
Constructs a new IP::Block
by interpreting the contents of a given String
.
Expects a definition in CIDR notation similar to [0-255].[0-255].[0-255].[0-255]/[0-32], XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/[0-128], or XXXX:XXXX::XXXX:XXXX:XXXX/[0-128].
Raises: MalformedError
when the input is malformed.
Constructs a new IP::Block
from an address and block size.
Raises: MalformedError
when the input is malformed.
Constructs a new IP::Block
by interpreting the contents of a given String
.
Expects a definition in CIDR notation similar to [0-255].[0-255].[0-255].[0-255]/[0-32], XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/[0-128], or XXXX:XXXX::XXXX:XXXX:XXXX/[0-128].
Returns nil
when the input is malformed.
Instance Method Detail
Compares this block to other returning true
if the other block falls before the
block.
Compares this block to other returning true
if the other block falls before or
inside the block.
Compares this block with the other block, returning -1
, 0
or +1
depending
if the block is less than, inclusive of, or greater than the other block.
Note: This is slightly different then the comparitors due to the added complexity
of a range of values. This is effective for ordering, not comparing inclusivity.
As such this object does not include Comparable
for IP::Block
s and the comparative
operators are added manually.
Compares this block with address, returning -1
, 0
or +1
depending if the
block is less than, inclusive of, or greater than the other address.
Compares this block to other returning true
if the other block is equal to the
receiver.
Compares this block to other returning true
if the other block falls after the
block.
Compares this block to other returning true
if the other block falls after or
inside the block.
Returns a Bool
indicating if the receiver is 'adjacent' to other. That is to
say the receiver is immidiatly beside, but not intersecting other.
Returns a Bool
indicating if the receiver is 'adjacent' to other. That is to
say the receiver is immidiatly beside, but not intersecting other.
Returns a Bool
indicating if the receiver 'covers' other. That is to say the receiver
completely includes other.
Returns a Bool
indicating if the receiver 'covers' other. That is to say the receiver
completely includes other.
Returns a Bool
indicating if the receiver 'includes' the other address.
Appends a type-specified presentation representation of the block to the
given IO
.
Returns a Bool
indicating if the receiver 'intersects' other. That is to say the receiver
partially includes other.
Returns a Bool
indicating if the receiver 'intersects' other. That is to say the receiver
partially includes other.