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