IPAddress::Prefix32
Inherits IPAddress::Prefix < Comparable < Comparable < Struct < Value < Object
Constants
32 bit mask for IPv4
Constructors
Class methods
Instance methods
Shortcut for the octecs in the dotted decimal representation.
prefix = IPAddress::Prefix32.new 24
prefix[2] # => 255
See also #octets
Transforms the prefix into a string of bits representing the netmask.
prefix = IPAddress::Prefix32.new 24
prefix.bits # => "11111111111111111111111100000000"
Returns the length of the host portion of a netmask.
prefix = IPAddress::Prefix32.new 24
prefix.host_prefix # => 8
Returns the wildcard mask, i.e. a mask of bits that indicates which parts of an IP address are available for examination.
A wildcard mask can be thought of as an inverted subnet mask.
For example, a subnet mask of 255.255.255.0 inverts to a
wildcard mask of 0.0.0.255.
prefix = IPAddress::Prefix32.new 24
prefix.hostmask # => "0.0.0.255"
An array of octets of the IPv4 dotted decimal format.
prefix = IPAddress::Prefix32.new 24
prefix.octets # => [255, 255, 255, 0]
See also #to_ip
Gives the prefix in IPv4 dotted decimal format, i.e. the canonical netmask we're all used to.
prefix = IPAddress::Prefix32.new 24
prefix.to_ip # => "255.255.255.0"
Unsigned 32 bits decimal number representing the prefix.
prefix = IPAddress::Prefix32.new 24
prefix.to_u32 # => 4294967040