Class: IPAddress::IPv4

Inherits:
Object
  • Object
show all
Defined in:
lib/biosphere/ipaddressallocator.rb

Instance Method Summary collapse

Instance Method Details

#allocate(skip = 0) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/biosphere/ipaddressallocator.rb', line 5

def allocate(skip = 0)
    if !@allocator
        @allocator = 1
    else
        @allocator += + 1
    end

    @allocator += skip

    next_ip = network_u32+@allocator
    if next_ip > broadcast_u32+1
        raise StopIteration
    end
    self.class.parse_u32(network_u32+@allocator, @prefix)
end