Sha256: f5281fe7f6007a089d380a7c865ee93b01c29b66e20fd28444c3e28a29f8d936
Contents?: true
Size: 674 Bytes
Versions: 4
Compression:
Stored size: 674 Bytes
Contents
class DeadlySerious::Engine::AutoPipe TEMPLATE = 'pipe.%s' class Counter TEMPLATE = '%04d' def initialize @counter = 0 end def next @counter += 1 last end def last format(TEMPLATE, @counter) end def zero? @counter == 0 end end def initialize @counters = [Counter.new] end def next current_counter.next last end def last return nil if current_counter.zero? format(TEMPLATE, @counters.map(&:last).join('.')) end def on_subnet @counters << Counter.new yield ensure @counters.pop end private def current_counter @counters.last end end
Version data entries
4 entries across 4 versions & 1 rubygems