Sha256: 5f3f27c380adb8d46577a9f94304fe4aa97508278ef74de2983623be9c1db7ad

Contents?: true

Size: 669 Bytes

Versions: 6

Compression:

Stored size: 669 Bytes

Contents

module Candle

  module Utility
    class XcodeUUIDGenerator

        def initialize
            @num = [Time.now.to_i, Process.pid, getMAC]
        end

        # Get the ethernet hardware address ("MAC"). This version
        # works on Mac OS X 10.6 (Snow Leopard); it has not been tested
        # on other versions.

        def getMAC(interface='en0')
            addrMAC = `ifconfig #{interface} ether`.split("\n")[1]
            addrMAC ? addrMAC.strip.split[1].gsub(':','').to_i(16) : 0
        end

        def generate
            @num[0] += 1
            self
        end

        def to_s
            "%08X%04X%012X" % @num
        end
    end
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
candle-0.0.7 lib/candle/utility.rb
candle-0.0.6 lib/candle/utility.rb
candle-0.0.4 lib/candle/utility.rb
candle-0.0.3 lib/candle/utility.rb
candle-0.0.2 lib/candle/utility.rb
candle-0.0.1 lib/candle/utility.rb