Method: NetAddr::IPv4Net#nth
- Defined in:
- lib/ipv4net.rb
#nth(index) ⇒ Object
nth returns the IPv4 at the given index. The size of the network may be determined with the len() method. If the range is exceeded then return nil.
114 115 116 117 118 119 120 121 |
# File 'lib/ipv4net.rb', line 114 def nth(index) if (!index.kind_of?(Integer)) raise ArgumentError, "Expected an Integer for 'index' but got a #{index.class}." elsif (index >= self.len) return nil end return IPv4.new(self.network.addr + index) end |