# File lib/uuid.rb, line 249
249:   def initialize
250:     @drift = 0
251:     @last_clock = (Time.now.to_f * CLOCK_MULTIPLIER).to_i
252:     @mutex = Mutex.new
253: 
254:     state_file = self.class.state_file
255:     if state_file && File.size?(state_file) then
256:       next_sequence
257:     else
258:       @mac = mac_address
259:       fail "Cannot determine MAC address from any available interface, tried with #{mac_address}" if @mac == 0
260:       @sequence = rand 0x10000
261: 
262:       # Ensure the mode is respected, even with a restrictive umask
263:       File.open(state_file, 'w') { |f| f.chmod(self.class.mode) } if state_file && !File.exists?(state_file)
264: 
265:       if state_file
266:         open_lock 'wb' do |io|
267:           write_state io
268:         end
269:       end
270:     end
271:   end