class Subnet::Prefix128

Defined in:

subnet/prefix.cr

Constructors

Instance Method Summary

Instance methods inherited from class Subnet::Prefix

+(other) +, -(other) -, <=>(other) <=>, prefix : Int32 prefix, prefix=(prefix : Int32) prefix=, to_i : Int32 to_i, to_s(io) to_s

Constructor methods inherited from class Subnet::Prefix

new(num) new

Constructor Detail

def self.new(num = 128) #

Creates a new prefix object for 128 bits IPv6 addresses

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

[View source]

Instance Method Detail

def bits #

Transforms the prefix into a string of bits representing the netmask

prefix = Subnet::Prefix128.new 64

prefix.bits
# => "1111111111111111111111111111111111111111111111111111111111111111 \
# => 0000000000000000000000000000000000000000000000000000000000000000"

[View source]
def host_prefix #

Returns the length of the host portion of a netmask.

prefix = Prefix128.new 96

prefix.host_prefix
# => 32

[View source]
def to_u128 #

Unsigned 128 bits decimal number representing the prefix

prefix = Subnet::Prefix128.new 64

prefix.to_u128
# => 340282366920938463444927863358058659840

[View source]