class Subnet::Prefix32
- Subnet::Prefix32
- Subnet::Prefix
- Reference
- Object
Defined in:
subnet/prefix.crConstant Summary
-
IN4MASK =
4294967295_i64
Constructors
-
.new(num)
Creates a new prefix object for 32 bits IPv4 addresses
Class Method Summary
-
.parse_netmask(netmask)
Creates a new prefix by parsing a netmask in dotted decimal form
Instance Method Summary
-
#[](index)
Shortcut for the octecs in the dotted decimal representation
-
#bits
Transforms the prefix into a string of bits representing the netmask
-
#host_prefix
Returns the length of the host portion of a netmask.
-
#hostmask
The hostmask is the contrary of the subnet mask, as it shows the bits that can change within the hosts
-
#hostmask_octets
Returns an array of octets representing the hostmask
-
#octets
An array of octets of the IPv4 dotted decimal format
-
#to_ip
Gives the prefix in IPv4 dotted decimal format, i.e.
-
#to_u32
Unsigned 32 bit number representing the prefix.
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
Creates a new prefix object for 32 bits IPv4 addresses
prefix = Subnet::Prefix32.new 24
# => 24
Class Method Detail
Creates a new prefix by parsing a netmask in dotted decimal form
prefix = Subnet::Prefix32::parse_netmask "255.255.255.0"
#=> 24
Instance Method Detail
Shortcut for the octecs in the dotted decimal representation
prefix = Subnet::Prefix32.new 24
prefix[2]
# => 255
Transforms the prefix into a string of bits representing the netmask
prefix = Subnet::Prefix32.new 24
prefix.bits
# => "11111111111111111111111100000000"
Returns the length of the host portion of a netmask.
prefix = Prefix32.new 24
prefix.host_prefix
# => 8
The hostmask is the contrary of the subnet mask, as it shows the bits that can change within the hosts
prefix = Subnet::Prefix32.new 24
prefix.hostmask
# => "0.0.0.255"
Returns an array of octets representing the hostmask
prefix = Subnet::Prefix32.new 24
prefix.hostmask_octets
# => StaticArray["0", "0", "0", "255"]
An array of octets of the IPv4 dotted decimal format
prefix = Subnet::Prefix32.new 24
prefix.octets
# => [255, 255, 255, 0]
Gives the prefix in IPv4 dotted decimal format, i.e. the canonical netmask we're all used to
prefix = Subnet::Prefix32.new 24
prefix.to_ip
# => "255.255.255.0"
Unsigned 32 bit number representing the prefix.
prefix = Subnet::Prefix32.new 24
prefix.to_u32
#=> 4294967040