Method: IPAddress::IPv4#each
- Defined in:
- lib/ipaddress/ipv4.rb
#each ⇒ Object
Iterates over all the IP addresses for the given network (or IP address).
The object yielded is a new IPv4 object created from the iteration.
ip = IPAddress("10.0.0.1/29")
ip.each do |i|
p i.address
end
#=> "10.0.0.0"
#=> "10.0.0.1"
#=> "10.0.0.2"
#=> "10.0.0.3"
#=> "10.0.0.4"
#=> "10.0.0.5"
#=> "10.0.0.6"
#=> "10.0.0.7"
473 474 475 476 477 |
# File 'lib/ipaddress/ipv4.rb', line 473 def each (network_u32..broadcast_u32).each do |i| yield self.class.parse_u32(i, @prefix) end end |