struct

IP::Block

Inherits Comparable < Struct < Value < Object

Constructors

[](string : String) : self

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.

Source
ipv4(string : String) : self

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.

Source
ipv6(string : String) : self

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.

Source
loopback_ipv4

Constructs a IP::Block:IPv4 representing the IPv4 loopback block.

Source
loopback_ipv6

Constructs a IP::Block:IPv4 representing the IPv4 loopback block.

Source
new(address : IP::Address, block : Int) : self | Nil

Constructs a new IP::Block from an address and block size.

Raises: MalformedError when the input is malformed.

Source
new(string : String) : self

ditto

Source

Class methods

[]?(string : String) : self | Nil

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.

Source
ipv4?(string : String) : self | Nil

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.

Source
ipv6?(string : String) : self | Nil

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.

Source
new?(address : IP::Address, block : Int) : self | Nil

ditto

Source
new?(string : String) : self | Nil

ditto

Source

Instance methods

<(other : IP::Block)

Compares this block to other returning true if the other block falls before the block.

Source
<=(other : IP::Block)

Compares this block to other returning true if the other block falls before or inside the block.

Source
<=>(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.

Source
<=>(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.

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::Blocks and the comparative operators are added manually.

Source
==(other : IP::Block)

Compares this block to other returning true if the other block is equal to the receiver.

Source
>(other : IP::Block)

Compares this block to other returning true if the other block falls after the block.

Source
>=(other : IP::Block)

Compares this block to other returning true if the other block falls after or inside the block.

Source
address

Returns the address component of the block which is also the first address.

Source
adjacent?(other : IP::Block) : Bool

Returns a Bool indicating if the receiver is 'adjacent' to other. That is to say the receiver is immidiatly beside, but not intersecting other.

Source
adjacent?(other : IP::Address) : Bool

ditto

Source
block

Returns 'block' size in the form aof 2^x, x being the 'size'.

Source
covers?(other : IP::Block) : Bool

Returns a Bool indicating if the receiver 'covers' other. That is to say the receiver completely includes other.

Source
covers?(other : IP::Address) : Bool

ditto

Source
each

Yield each address to the block.

Source
first

Returns the first address in the block.

Source
hash(hasher)

See Object#hash(hasher)

Source
includes?(other : IP::Address) : Bool

Returns a Bool indicating if the receiver 'includes' the other address.

Source
inspect(io : IO) : Nil

Appends a type-specified presentation representation of the block to the given IO.

Source
intersects?(other : IP::Block) : Bool

Returns a Bool indicating if the receiver 'intersects' other. That is to say the receiver partially includes other.

Source
intersects?(other : IP::Address) : Bool

ditto

Source
ipv4?

Informs if the block is IPv4 or not.

Source
ipv6?

Informs if the block is IPv6 or not.

Source
last

Returns the last address in the block.

Source
mask

Returns the blocks mask.

Source
single_address?

Informs if the block is a single address or not.

Source
size

Returns the size of the block in terms of number of addresses.

Source
to_s(io : IO) : Nil

Appends the presentation representation of the block to the given IO.

Source

Nested types