lib/ipaddress_2/ipv6.rb
#
# Returns a new IPv4 object from the supernetting
# of the instance network.
#
# Supernetting is similar to subnetting, except
# that you getting as a result a network with a
# smaller prefix (bigger host space). For example,
# given the network
#
#   ip = IPAddress("2001:db8:8:800::1/64")
#
# you can supernet it with a new /32 prefix
#
#   ip.supernet(32).to_string
#     #=> "2001:db8::/32"
#
# However if you supernet it with a /22 prefix, the
# network address will change:
#
#   ip.supernet(22).to_string
#     #=> "2001:c00::/22"
#
# If +new_prefix+ is less than 1, returns 0000:0000:0000:0000:0000:0000:0000:0000/0
#
Returns a new IPv4 object from the supernetting
of the instance network.

Supernetting is similar to subnetting, except
that you getting as a result a network with a
smaller prefix (bigger host space). For example,
given the network



you can supernet it with a new /32 prefix



However if you supernet it with a /22 prefix, the
network address will change.




Returns a new IPv4 object from the supernetting of the instance network . Supernetting is similar to subnetting except that you getting as a result a network with a smaller prefix ( bigger host space ) . For example given the network you can supernet it with a new / 32 prefix However if you supernet it with a / 22 prefix the network address will change .
def supernet(new_prefix)
      raise ArgumentError, "New prefix must be smaller than existing prefix" if new_prefix >= @prefix.to_i
      return self.class.new("0000:0000:0000:0000:0000:0000:0000:0000/0") if new_prefix < 1
      return self.class.new(@address+"/#{new_prefix}").network
    end
def supernet ( new_prefix ) raise ArgumentError , "New prefix must be smaller than existing prefix" if new_prefix >= @prefix . to_i return self . class . new ( "0000:0000:0000:0000:0000:0000:0000:0000/0" ) if new_prefix < 1 return self . class . new ( @address + "/#{new_prefix}" ) . network end
Returns a new IPv4 object from the supernetting
of the instance network.
Returns a new IPv4 object from the supernetting of the instance network .
new_prefix
<not_specific>