Creates a new prefix object for 128 bits IPv6 addresses
prefix = IPAddress::Prefix128.new 64 #=> 64
# File lib/ipaddress/prefix.rb, line 216 def initialize(num=128) unless (1..128).include? num.to_i raise ArgumentError, "Prefix must be in range 1..128, got: #{num}" end super(num.to_i) end
Transforms the prefix into a string of bits representing the netmask
prefix = IPAddress::Prefix128.new 64 prefix.bits #=> "1111111111111111111111111111111111111111111111111111111111111111" "0000000000000000000000000000000000000000000000000000000000000000"
# File lib/ipaddress/prefix.rb, line 233 def bits "1" * @prefix + "0" * (128 - @prefix) end
Generated with the Darkfish Rdoc Generator 2.