lib/ipaddress_2/ipv6.rb in ipaddress_2-0.12.0 vs lib/ipaddress_2/ipv6.rb in ipaddress_2-0.12.1
- old
+ new
@@ -987,20 +987,21 @@
# #=> ["2001:db8:8:801::/64","2001:db8:8:802::/63","2001:db8:8:804::/64"]
#
def self.summarize(*args)
# one network? no need to summarize
return [args.first.network] if args.size == 1
+ args_size = args.size
i = 0
- result = args.dup.sort.map{|ip| ip.network}
+ result = args.sort.map{|ip| ip.network}
while i < result.size-1
sum = result[i] + result[i+1]
result[i..i+1] = sum.first if sum.size == 1
i += 1
end
result.flatten!
- if result.size == args.size
+ if result.size == args_size
# nothing more to summarize
return result
else
# keep on summarizing
return self.summarize(*result)