# File lib/json-schema/uri/uuid.rb, line 140
                def create clock=nil, time=nil, mac_addr=nil
                        c = t = m = nil
                        Dir.chdir Dir.tmpdir do
                                unless FileTest.exist? STATE_FILE then
                                        # Generate a pseudo MAC address because we have no pure-ruby way
                                        # to know  the MAC  address of the  NIC this system  uses.  Note
                                        # that cheating  with pseudo arresses here  is completely legal:
                                        # see Section 4.5 of RFC4122 for details.
                                        sha1 = Digest::SHA1.new
                                        256.times do
                                                r = [rand(0x100000000)].pack "N"
                                                sha1.update r
                                        end
                                        str = sha1.digest
                                        r = rand 14 # 20-6
                                        node = str[r, 6] || str
                                        if RUBY_VERSION >= "1.9.0"
                                                nnode = node.bytes.to_a
                                                nnode[0] |= 0x01
                                                node = ''
                                                nnode.each { |s| node << s.chr }
                                        else
                                                node[0] |= 0x01 # multicast bit
                                        end
                                        k = rand 0x40000
                                        open STATE_FILE, 'w' do |fp|
                                                fp.flock IO::LOCK_EX
                                                write_state fp, k, node
                                                fp.chmod 0o777 # must be world writable
                                        end
                                end
                                open STATE_FILE, 'r+' do |fp|
                                        fp.flock IO::LOCK_EX
                                        c, m = read_state fp
                                        c = clock % 0x4000 if clock
                                        m = mac_addr if mac_addr
                                        t = time
                                        if t.nil? then
                                                # UUID epoch is 1582/Oct/15
                                                tt = Time.now
                                                t = tt.to_i*10000000 + tt.tv_usec*10 + 0x01B21DD213814000
                                        end
                                        c = c.succ # important; increment here
                                        write_state fp, c, m
                                end
                        end

                        tl = t & 0xFFFF_FFFF
                        tm = t >> 32
                        tm = tm & 0xFFFF
                        th = t >> 48
                        th = th & 0x0FFF
                        th = th | 0x1000
                        cl = c & 0xFF
                        ch = c & 0x3F00
                        ch = ch >> 8
                        ch = ch | 0x80
                        pack tl, tm, th, cl, ch, m
                end