Method: NetAddr::IPv6Net#nth_subnet

Defined in:
lib/ipv6net.rb

#nth_subnet(prefix_len, index) ⇒ Object

nth_subnet returns the subnet IPv6Net at the given index. The number of subnets may be determined with the subnet_count() method. If the range is exceeded or an invalid prefix_len is provided then return nil.



127
128
129
130
131
132
133
134
# File 'lib/ipv6net.rb', line 127

def nth_subnet(prefix_len,index)
  count = self.subnet_count(prefix_len)
  if (count == 0 || index >= count)
    return nil
  end
  sub0 = IPv6Net.new(self.network, Mask128.new(prefix_len))
  return sub0.nth_next_sib(index)
end