Method: NetAddr::IPv4Net#nth_subnet
- Defined in:
- lib/ipv4net.rb
#nth_subnet(prefix_len, index) ⇒ Object
nth_subnet returns the subnet IPv4Net 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.
126 127 128 129 130 131 132 133 |
# File 'lib/ipv4net.rb', line 126 def nth_subnet(prefix_len,index) count = self.subnet_count(prefix_len) if (count == 0 || index >= count) return nil end sub0 = IPv4Net.new(self.network, Mask32.new(prefix_len)) return sub0.nth_next_sib(index) end |