Class: Puer::Utility::XcodeUUIDGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/puer/utility.rb

Instance Method Summary collapse

Constructor Details

#initializeXcodeUUIDGenerator

Returns a new instance of XcodeUUIDGenerator.



6
7
8
# File 'lib/puer/utility.rb', line 6

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

Instance Method Details

#generateObject



19
20
21
22
# File 'lib/puer/utility.rb', line 19

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

#getMAC(interface = 'en0') ⇒ Object

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.



14
15
16
17
# File 'lib/puer/utility.rb', line 14

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

#to_sObject



24
25
26
# File 'lib/puer/utility.rb', line 24

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