struct IPAddress::Prefix128

Defined in:

ipaddress/prefix.cr

Constructors

Instance Method Summary

Instance methods inherited from struct IPAddress::Prefix

+(other : Prefix) : Int
+(other : Int) : Int
+
, -(other : Prefix) : Int
-(other : Int) : Int
-
, <=>(other : Prefix)
<=>(other : Int)
<=>
, hash(hasher) hash, pred : Prefix pred, prefix : Int32 prefix, succ : Prefix succ, to_i : Int32 to_i, to_s(io : IO) to_s

Constructor methods inherited from struct IPAddress::Prefix

new(prefix : Int) new

Constructor Detail

def self.new(prefix : Int32 = 128) #

Creates a new prefix object for 128 bits IPv6 addresses.

prefix = IPAddress::Prefix128.new 64 # => 64

[View source]

Instance Method Detail

def bits : String #

Transforms the prefix into a string of bits representing the netmask.

prefix = IPAddress::Prefix128.new 64
prefix.bits
  # => "1111111111111111111111111111111111111111111111111111111111111111"
       "0000000000000000000000000000000000000000000000000000000000000000"

[View source]
def host_prefix : Int32 #

Returns the length of the host portion of a netmask.

prefix = IPAddress::Prefix128.new 96
prefix.host_prefix # => 32

[View source]
def to_big_i : BigInt #

Returns unsigned 128 bits decimal number representing the prefix as BigInt.

prefix = IPAddress::Prefix128.new 64
prefix.to_big_i # => 340282366920938463444927863358058659840

[View source]