Sha256: 2798e7f6c54c25b08b681d9a7bc43aebeeee7095bcb78e466d3856ee3a99c8f5
Contents?: true
Size: 570 Bytes
Versions: 6
Compression:
Stored size: 570 Bytes
Contents
module Clusterfuck class SubnetFactory attr_reader :last_ip START_SUBNET = "10.0.39.0/24" @previous = IPAddr.new(START_SUBNET) def initialize(last_ip) @last_ip = last_ip end def next_ip @last_ip = @last_ip.succ end def self.next_subnet(cidr = 24) # `succ` twice to start at x.x.2.1, for example: # 10.0.39.1 -> 10.0.40.1 @previous = @previous.mask(cidr).to_range.last.succ.succ SubnetFactory.new(@previous) end def self.reset @previous = IPAddr.new(START_SUBNET) end end end
Version data entries
6 entries across 6 versions & 1 rubygems