lib/ipaddress/prefix.rb in ipaddress-0.7.0 vs lib/ipaddress/prefix.rb in ipaddress-0.7.5

- old
+ new

@@ -90,12 +90,12 @@ # # prefix = IPAddress::Prefix32.new 24 # #=> 24 # def initialize(num) - unless (1..32).include? num - raise ArgumentError, "Prefix must be in range 1..32, got: #{num}" + unless (0..32).include? num + raise ArgumentError, "Prefix must be in range 0..32, got: #{num}" end super(num) end # @@ -119,10 +119,10 @@ # # prefix.bits # #=> "11111111111111111111111100000000" # def bits - to_u32.to_s(2) + "%.32b" % to_u32 end # # Gives the prefix in IPv4 dotted decimal format, # i.e. the canonical netmask we're all used to