Sha256: cb7094c32395ca966d9656f4aa7ab0e0415319f3b4b3f3c9d443d820af3cd6c4
Contents?: true
Size: 961 Bytes
Versions: 1
Compression:
Stored size: 961 Bytes
Contents
require 'auto_network' require 'ipaddress' module AutoNetwork class Pool class PoolExhaustedError < StandardError; end # Provide a single instance of this class # # @return [AutoNetwork::Pool] def self.instance @myself ||= new end # @param addr [String] The network address range to use as the address pool. # Defaults to `AutoNetwork.default_pool` def initialize(addr = AutoNetwork.default_pool) @addr = addr @network = IPAddress.parse(addr) @range = @network.hosts # Drop the first IP address as it should be reserved for the host system @range.shift end # @return [String] The string representation of the next available address # @raise [PoolExhaustedError] There are no remaining addresses in the pool. def next if @range.empty? raise PoolExhaustedError, "No addresses remaining in network address pool #{addr.inspect}" end addr = @range.shift addr.address end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-auto_network-0.1.0 | lib/auto_network/pool.rb |